Visual Basic Q&A

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries Tagged ‘control’

BUG: Data Control Validate Event Not Fired on Unloading Form

Symptoms
A form containing a bound Data Control disables the Validate event when theform is unloaded.
Resolution
Microsoft has confirmed this to be an issue in the Microsoft productslisted at the beginning of this article. Microsoft is researching thisissue and will post new information here in the Microsoft Knowledge Base asit becomes available.

BUG: Data Control NoMatch Equals True Returns Error

Symptoms
When the NoMatch method of the Data Control returns “True,” the Seek methodwill report a run-time error “No Current Record.”
Resolution
The user can work around this problem by trapping the Data Control’s errorevent and repositioning to an existing record after the seek failure.

BUG: Data Control Errors Do Not Populate Error Object

Symptoms
A “Type Mismatch” error is generated when a control is bound to a fieldwith an incompatible type, but the Error object is not populated when it isexamined in the Data Control Error event.
Resolution
This is a limitation of the Data Control in Visual Basic version 4.0. Whenthe DAO generates an error, the Error object is cleared when the Errorevent for the Data Control is fired.

BUG: All check boxes are cleared in a data-bound CheckedListBox control when rows are added to the DataTable control

Symptoms
You have a data-bound CheckedListBox control on your Windows Form. When you click to select some items in the CheckedListBox control at runtime and then you add a new row to the DataTable control that is bound to the CheckedListBox control, all the check boxes on the control are cleared.
Note Check boxes are not cleared when the CheckedListBox control is not data-bound.
Resolution
This problem occurs because the CheckedListBox control is not designed for data binding.

PRB: DataGrid Control Does Not Return Contents of Edited Cell

Symptoms
The Microsoft DataGrid Control 6.0 (OLEDB) does not return the contents ofan edited cell.
Using the CellText properties of the Column object returns the originalvalue of the text currently in the cell and not the text the user hasedited. This behavior differs from the Data Bound Grid Control that returnsthe value of the user-edited text.
This scenario may be problematic for a developer who would like to validatethe contents of the cell before the contents are placed in the recordset.
Resolution
The DataGrid control provides a window handle to the cell being edited.Using this handle and the GetWindowText API, the developer can get thecontents of the edited cell before the contents are saved in the recordset.

PRB: COleControl::Serialize Not Called with VB as Container

Symptoms
Although OLE controls are used with certain control containers (such asMicrosoft Visual Basic version 4.0), the Serialize function for the control-derived class is not called. These containers allow the control to storeits persistent information either by using the property sets or by usingthe IPersistPropertyBag interface. Both these methods callCOleControl::DoPropExchange directly without calling the control’sSerialize function.
The resolution section of this article discusses a technique that you canuse in the DoPropExchange method to store CObject-derived objects.
Resolution
COleControl::Serialize is called by the framework when an OLE controlcontainer uses one of the following persistent storage interfaces forloading and saving the control: IPersistStorage, IPersistStreamInit, orIPersistMemory.
If a control container uses any other method to store the control’spersistent information, then Serialize for the control-derived class willnot be called. Microsoft Visual Basic, for example, uses eitherIPersistPropertyBag or property sets to store the persistent informationfor an OLE control; therefore, the Serialize function for a control is notcalled when Visual Basic is used as the control container.