Uprading VB6 MSFlexGrid to VB.NET

為{幸葍}努か 提交于 2020-01-14 02:55:05

问题


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

回答1:


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.




回答2:


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)


来源:https://stackoverflow.com/questions/6787946/uprading-vb6-msflexgrid-to-vb-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!