我正在使用此代码将datagridview的名称添加到第1列
Dim scAutoComplete As AutoCompleteStringCollection
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
scAutoComplete = New AutoCompleteStringCollection
If con.State = ConnectionState.Closed Then con.Open()
Dim cmd As SqlCeCommand
cmd = New SqlCeCommand("Select id ,name from tab_name", con)
Dim dr = cmd.ExecuteReader()
While dr.Read
scAutoComplete.Add(dr(1))
End While
End Sub
Private Sub DataGridView_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles DGV.EditingControlShowing
Dim ItemCode As TextBox = TryCast(e.Control, TextBox)
If ItemCode IsNot Nothing Then
If DGV.CurrentCell.ColumnIndex = 1 Then
ItemCode.AutoCompleteMode = AutoCompleteMode.SuggestAppend
ItemCode.AutoCompleteCustomSource = scAutoComplete
ItemCode.AutoCompleteSource = AutoCompleteSource.CustomSource
Else
ItemCode.AutoCompleteMode = AutoCompleteMode.None
End If
End If
End Sub
我想读取行号,将id添加到列(0)
答案 0 :(得分:0)
您应该能够使用DataGridView.CurrentCellAddress来获取行