VB6/VBA MSFlexGrid to VB.NET DataGridView

Logan B. Lehman picture Logan B. Lehman · Mar 17, 2012 · Viewed 7.4k times · Source

Yet again, more fantastic VB6 to VB.NET migration.

Okay sure, this isn't necessarily a "Question" in definition, but it will answer many questions that users will have in the future, and will hopefully answer my questions as well.

I am trying to compile a list of properties and functions within MSFlexGrid in VB6/VBA and .NET's DataGridView that provide the same or somewhat same uses. Not only do I need them, but I am sure there are more who do.

So far this is what I have, and I would like others to feel free to add and edit as you please. I hoping this helps me and others convert old controls into .NET controls with the same functionality as in their old code. If you feel like adding, please enter the relation in the BlockQuote and the definition in its proprietary place:

VB6/VBA                          VB.NET

MSFlexGrid.Cols         :::::    DataGridView.ColumnCount
MSFlexGrid.Col          :::::    ???
MSFlexGrid.Rows         :::::    DataGridView.RowCount
MSFlexGrid.Row          :::::    ???
MSFlexGrid.TextMatrix   :::::    DataGridView.Item(Int32,Int32).Value
MSFlexGrid.TextArray    :::::    ???
Add More Here           :::::    Add More Here

Definitions VB6:

  1. MSFlexGrid.Cols = Returns or sets the total number of columns in an MSFlexGrid.

  2. MSFlexGrid.Col = Returns or sets the coordinates of the active cell in an MSFlexGrid.

  3. MSFlexGrid.Rows = Returns or sets the total number of rows in an MSFlexGrid.

  4. MSFlexGrid.Row = Returns or sets the coordinates of the active cell in an MSFlexGrid.

  5. MSFlexGrid.TextMatrix = Returns or sets the text contents of an arbitrary cell. This property allows you to set or retrieve the contents of a cell without changing the Row and Col properties

  6. MSFlexGrid.TextArray = Returns or sets the text content of an arbitrary cell. This property allows you to set or retrieve the contents of a cell without changing the Row and Col properties.

  7. Add More Here


Definitions VB.NET:

  1. DataGridView.ColumnCount = Gets or sets the number of columns displayed in the DataGridView.

  2. DataGridView.RowCount = Gets or sets the number of rows displayed in the DataGridView.

  3. DataGridView.Item(Int32,Int32).Value = Provides an indexer to get or set the cell located at the intersection of the column and row with the specified indexes, and then returns the value.

  4. Add More Here

Answer

Jose C picture Jose C · Aug 6, 2013

For Row and Col properties you could use something like:

    Public Class MyGrid
    Inherits System.Windows.Forms.DataGridView
(...)
    Public Property Col() As Integer
        Get
                Return Me.CurrentCell.ColumnIndex
        End Get
        Set(ByVal value As Integer)
                    Me.CurrentCell = Me(value, Me.CurrentCell.RowIndex)
            End If
        End Set
    End Property
(...)
    Public Property Row() As Integer
        Get
                Return Me.CurrentCell.RowIndex
        End Get
        Set(ByVal value As Integer)
                    Me.CurrentCell = Me(value, Me.CurrentCell.ColumnIndex)
            End If
        End Set
    End Property
(...)
End Class

Then keep looking and matching every property, method and events with the original control.