开发者

Uprading VB6 MSFlexGrid to VB.NET

I want to upgrade MSFlexGrid to .net datagridview, what is equivalent code for these code??

With gridview
    If .Row > .FixedRows Then
        bDoNotEdit = True
        .Row = 开发者_运维问答.Row - 1
        bDoNotEdit = False
    End If
    If .Row < .Rows - 1 Then
        bDoNotEdit = True
        .Row = .Row + 1
        bDoNotEdit = False
    End If
End With


Using a data grid view.

The code segment assumes that you have created a datagridview control named "SubmittedDataGridView" and have created the columns in the IDE at design-time, or have specified them at run-time before you get here.

I do not know what the variable "bDoNotEdit" means or is used for, so I've ignored it.

'step one, create a datagridrow
Dim aRow As New System.Windows.Forms.DataGridViewRow

'Step two, create a prototypical Row from the datagridview control
aRow.CreateCells(SubmittedDataGridView)

'Step Three, specify the values
aRow.Cells(0).Value = "value one"
aRow.Cells(1).Value = "Value two"
aRow.Cells(2).Value = "value three"

'Append the row to the DataGridView
SubmittedDataGridView.Rows.Add(aRow)


While VS 2008 and earlier can migrate a VB6 application to .Net, it won't use the .Net idioms (particularly the better databinding functionality). VS2010 removed the migration wizard. The real question here is what ultimatly are you trying to accomplish with this code? Often it is best to rethink/rewrite the problem than to just use the default migrated code. I've found projects where litterally thousands of lines of code could be removed by using .Net databinding against objects.

Also, realize that just because the migrated code might compile, it might not be doing the same thing. In particular look out for off by one errors with the lower bounds of arrays or math functions using boolean results.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜