Export (0) Print
Expand All
Expand Minimize

DataGrid Control Changes in Visual Basic .NET

The DataGrid control in Visual Basic 6.0 is replaced by the Windows Forms DataGrid control in Visual Basic .NET. The names of some properties, methods, events, and constants are different, and in some cases there are differences in behavior. The following table lists Visual Basic 6.0 properties and their Visual Basic .NET equivalents.

The Visual Basic .NET DataGrid 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.

Properties for viewing and navigation in the DataGrid (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 details, see Keyboard Shortcuts for the Windows Forms DataGrid Control.

DataGrid Properties

Visual Basic 6.0Visual Basic .NET Equivalent
AddNewModeNo equivalent.
AlignDock and Anchor
AllowAddNewOn DataView object; accessed through AllowNew property of DataView class.
AllowArrowsNo longer an adjustable property: arrow navigation always allowed.
AllowDeleteOn DataView object; accessed through AllowDelete property of DataView class.
AllowRowSizingNo longer an adjustable property: row sizing always allowed.
AllowUpdateOn DataView object; accessed through AllowEdit property of DataView class.
AppearanceBorderStyle
ApproxCountOn BindingManagerBase object, returned by BindingContext object; accessed through Count property of the BindingManagerBase class.
BackColorBackColor affects only odd-numbered rows; AlternatingBackColor affects only even-numbered rows.
Note   Colors are handled differently in Visual Basic .NET. For more information, see Color Behavior Changes in Visual Basic .NET.

For a list of constants, see Color Changes in Visual Basic .NET.

BookmarkYou can now directly access any item.
CaptionCaptionText
CausesValidationCausesValidation
ColOn the DataGridCell structure; accessed by DataGrid.CurrentCell.ColumnNumber
ColumnHeadersColumnHeadersVisible

RowHeadersVisible

ColumnsOn the DataGridTableStyle object; accessed by DataGrid.TableStyle.GridColumnStyles.
ContainerParent; inherited from Control.
CurrentCellModifiedRowState property on DataRow object.
CurrentCellVisibleIf CurrentCell properties are set to a cell that is not visible, the grid will scroll to show that cell (similar to CurrentCellVisible = true).
DataBindingsDataBindings
DataChangedOn DataTable object; accessed by GetChanges method of DataTable class.
DataFormatsFormat property on DataGridTextBoxColumn object.
DataMemberDataMember
DataSourceDataSource
DefColWidthPreferredColumnWidth
DragIconSee GiveFeedbackEventArgs Class.
DragModeSee Control.DoDragDrop Method.
EditActiveNo equivalent.
EnabledEnabled
ErrorTextOn DataRow object; accessed by RowError property of DataRow class.
FirstRowSet Position property to 0 on BindingManagerBase object
FontFont
Note   Fonts are handled differently in Visual Basic .NET. For more information, see Font Changes in Visual Basic .NET
ForeColorForeColor
Note   Colors are handled differently in Visual Basic .NET. For more information, see Color Behavior Changes in Visual Basic .NET.

For a list of constants, see Color Changes in Visual Basic .NET.

HeadFontHeaderFont
Note   Fonts are handled differently in Visual Basic .NET. For more information, see Font Changes in Visual Basic .NET
HeadLinesNo equivalent.
HeightHeight, inherited from Control class
Note   Coordinates are handled differently in Visual Basic .NET. For more information, see Coordinate System Changes in Visual Basic .NET.
HelpContextIDOn HelpProvider extender control; accessed by SetHelpKeyword method of HelpProvider control.
hWndHandle
hWndEditorNo equivalent.
IndexNo equivalent.
LeftLeft
LeftColNo equivalent.
MarqueeStyleCell is highlighted when selected
NameNot available at run time
ObjectNo equivalent.
ParentParent, inherited from Control class
RecordSelectorsRowHeadersVisible
RightToLeftRightToLeft
RowOn DataGridCell structure; accessed by DataGrid.CurrentCell.RowNumber.
RowDividerStyleGridLineStyle
RowHeightNo equivalent.
ScrollBarsNo longer an adjustable property; the default behavior is ScrollBars = true.
SelBookmarksNo equivalent.
SelEndColNo equivalent.
SelLengthNo equivalent.
SelStartNo equivalent.
SelStartColNo equivalent.
SelTextNo equivalent.
SplitNo equivalent.
SplitsNo equivalent.
TabAcrossSplitsNo equivalent.
TabActionNo longer an adjustable property. The default behavior is for the focus to move to the next column when the TAB key is pressed (dbgColumnNavigation). You can move the focus to the next control on the form (dbgControlNavigation) by pressing CTRL+TAB.
TabIndexTabIndex
TabStopTabStop
TagNo equivalent.
TextItem, when set to the current cell. For example:
Dim SelectedCellText As String = DataGrid1.Item(DataGrid1.CurrentCell)
ToolTipTextOn ToolTip extender control; accessed by SetToolTip method of ToolTip control
TopTop
VisibleVisible
VisibleColsVisibleColumnCount
VisibleRowsVisibleRowCount
WhatsThisHelpIDOn HelpProvider extender control; accessed by SetHelpString method of HelpProvider control
WidthWidth, inherited from Control class
Note   Coordinates are handled differently in Visual Basic .NET. For more information, see Coordinate System Changes in Visual Basic .NET.
WrapCellPointerNo longer an adjustable property; default behavior is WrapCellPointer = true.

See Also

Keyboard Shortcuts for the Windows Forms DataGrid Control | Introduction to the Windows Forms DataGrid Control | What's New in Windows Forms and Controls | DataGrid Control (Windows Forms) | Controls and Programmable Objects Compared in Different Languages and Libraries | Data Changes in Visual Basic .NET | Control Changes in Visual Basic .NET | Windows Forms Data Architecture

Show:
© 2015 Microsoft