[英]Uprading VB6 MSFlexGrid to VB.NET
我想將 MSFlexGrid 升級到 .net datagridview,這些代碼的等效代碼是什么?
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
使用數據網格視圖。
該代碼段假定您已經創建了一個名為“SubmittedDataGridView”的 datagridview 控件,並在設計時在 IDE 中創建了列,或者在您到達此處之前在運行時指定了它們。
我不知道變量“ bDoNotEdit ”的含義或用途,所以我忽略了它。
'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)
雖然 VS 2008 及更早版本可以將 VB6 應用程序遷移到 .Net,但它不會使用 .Net 慣用語(尤其是更好的數據綁定功能)。 VS2010 移除了遷移向導。 這里真正的問題是你最終想用這段代碼完成什么? 通常最好重新考慮/重寫問題,而不是只使用默認的遷移代碼。 我發現可以通過對對象使用.Net 數據綁定來刪除數千行代碼的項目。
另外,要意識到僅僅因為遷移的代碼可能會編譯,它可能不會做同樣的事情。 特別要注意 arrays 的下限或使用 boolean 結果的數學函數的錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.