DataGrid Control for Visual Basic 6.0 Users
The DataGrid control in Visual Basic 6.0 is replaced by the Windows Forms DataGridView control in Visual Basic 2005. The names of some properties, methods, events, and constants are different, and in some cases there are differences in behavior.
Conceptual Differences
Data Binding
The Visual Basic 2005 DataGridView control does not need data-specific methods or events because all actions are performed through the data source. Because of this separation of presentation and data functionality, the data source can be changed with or without user interface input. Also, multiple controls bound to the same data source will always stay in sync.
Navigation
Properties for viewing and navigation in the DataGrid control (such as TabAction, EnterAction, AllowArrows, WrapCellPointer, and Scrollable) are no longer needed. For example, the grid functions as though the Scrollable property is set to True: If more data exists than can be displayed, a scroll bar appears automatically. Excel-style navigation through the grid is the default, allowing the user to move forward with the TAB key and backward with the SHIFT+TAB key combination. For more information, see Default Keyboard and Mouse Handling in the Windows Forms DataGridView Control.
Caption Property
In Visual Basic 6.0, the Caption property is used to display a title bar above the grid; if the Caption property is left empty, no title bar is displayed.
The Visual Basic 2005 DataGridView control does not support a title bar. However, you can achieve the same effect using a Label control.
Data Formatting
In Visual Basic 6.0, formatting data in the DataGrid control is handled using the DataFormat property and a StdDataFormat object. Formatting is applied on a column-by-column basis.
In the Visual Basic 2005 DataGridView control, formatting is accomplished using the Format property of a DataGridViewCellStyle object. Formatting can be applied to individual cells, columns, or rows. For more information, see Data Formatting in the Windows Forms DataGridView Control.
hWndEditor Property
In Visual Basic 6.0, the hWndEditor property is used to pass the window handle assigned to a DataGrid control's editing window to a Windows API call.
The Visual Basic 2005 DataGridView control does not have a separate window handle when in edit mode; instead, use the Handle property of the DataGridView control or any embedded edit controls.
MarqueeStyle Property
In Visual Basic 6.0, the MarqueeStyle property controls the appearance of a selected cell or row by changing the border style, inverting the foreground and background colors, or invoking an edit window.
There is no direct equivalent for the Visual Basic 2005 DataGridView control. However, you can achieve the same effect through a combination of the SelectionMode, CellBorderStyle, and Format properties. For more information, see Selection Modes in the Windows Forms DataGridView Control.
SelLength, SelStart, SelText Properties
In the Visual Basic 6.0 DataGrid control, when a cell enters edit mode, the SelLength, SelStart, and SelText properties can be used to set the initial position of the caret or to highlight a portion of the text in the cell.
In the Visual Basic 2005 DataGridView control, these properties no longer exist. The cells in the DataGridView control are based on the TextBox control; by adding code to the EditingControlShowing event handler you can access the SelectionLength, SelectionStart, and SelectedText properties of the underlying control.
Split Views
The Visual Basic 6.0 DataGrid control supports a split view, allowing the user to display the same data side-by-side. The Split object and the Split, Splits, and TabAcrossSplits properties control the ability to display a split view.
In the Visual Basic 2005 DataGridView control, these properties no longer exist. However, you can achieve the same effect using one or more SplitContainer controls and multiple DataGridView controls. To duplicate the functionality of the TabAcrossSplits property, you can use the StandardTab property of the DataGridView control.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment