由于刚才程序问题重发一遍
问题为::没有为 类型“DataTable” 和 'Nothing' 定义运算符“=”。
请高手帮忙解决
Private Sub DataGridView1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView1.Click
If Button3.Text = "你" Then
If DataGridView1.CurrentCell.ColumnIndex = 2 Then
If ComboBox1.DataSource = Nothing Then‘问题出现处
End If
ComboBox1.Left = DataGridView1.GetCellDisplayRectangle(DataGridView1.CurrentCell.ColumnIndex, DataGridView1.CurrentCell.RowIndex, True).Left
'(上两行是一行,叶面不够,写代码时要写在一行)
ComboBox1.Top = DataGridView1.GetCellDisplayRectangle(DataGridView1.CurrentCell.ColumnIndex, DataGridView1.CurrentCell.RowIndex, True).Top
' (上两行是一行,叶面不够,写代码时要写在一行)
ComboBox1.Text = DataGridView1.CurrentCell.Value '.ToString()
ComboBox1.Width = DataGridView1.GetCellDisplayRectangle(DataGridView1.CurrentCell.ColumnIndex, DataGridView1.CurrentCell.RowIndex, True).Width
'(上两行是一行,叶面不够,写代码时要写在一行)
ComboBox1.Visible = True
'Dim sp() As String = New String() {"1", "21", "30"}
' Dim installs() As String = New String() _
' {"Typical", "Compact", "Custom"}
' ComboBox1.Items.AddRange(installs)
ElseIf DataGridView1.CurrentCell.ColumnIndex = 3 Then
ComboBox1.DataSource = Nothing
ComboBox1.Items.Clear()
Dim ab As String() = New String() {"1", "2<", "3"}
ComboBox1.Items.AddRange(ab)
ComboBox1.Left = DataGridView1.GetCellDisplayRectangle(DataGridView1.CurrentCell.ColumnIndex, DataGridView1.CurrentCell.RowIndex, True).Left
'(上两行是一行,叶面不够,写代码时要写在一行)
ComboBox1.Top = DataGridView1.GetCellDisplayRectangle(DataGridView1.CurrentCell.ColumnIndex, DataGridView1.CurrentCell.RowIndex, True).Top
' (上两行是一行,叶面不够,写代码时要写在一行)
ComboBox1.Text = DataGridView1.CurrentCell.Value '.ToString()
ComboBox1.Width = DataGridView1.GetCellDisplayRectangle(DataGridView1.CurrentCell.ColumnIndex, DataGridView1.CurrentCell.RowIndex, True).Width
'(上两行是一行,叶面不够,写代码时要写在一行)
ComboBox1.Visible = True
'Dim sp() As String = New String() {"1", "21", "30"}
' Dim installs() As String = New String() _
' {"Typical", "Compact", "Custom"}
' ComboBox1.Items.AddRange(installs)
Else
ComboBox1.Visible = False
ComboBox1.Width = 0
ComboBox1.DataSource = Nothing
ComboBox1.Items.Clear()
End If
End If
End Sub
Private Sub ComboBox1_SelectionChangeCommitted(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectionChangeCommitted
If DataGridView1.CurrentCell.ColumnIndex = 2 Then
DataGridView1.CurrentCell.Value = ComboBox1.SelectedValue
Else
DataGridView1.CurrentCell.Value = ComboBox1.SelectedItem
End If
End Sub
娌℃湁涓?绫诲瀷鈥淒ataTable鈥?鍜?'Nothing' 瀹氫箟杩愮畻绗︹€?鈥濄€? Private Sub DataGridView1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView1.Click
If Button3.Text = "浣? Then
If DataGridView1.CurrentCell.ColumnIndex = 2 Then
If ComboBox1.DataSource = Nothing Then
End If
ComboBox1.Left = DataGridView1.GetCellDisplayRectangle(DataGridView1.CurrentCell.ColumnIndex, DataGridView1.CurrentCell.RowIndex, True).Left
'锛堜笂涓よ鏄竴琛岋紝鍙堕潰涓嶅锛屽啓浠g爜鏃惰鍐欏湪涓€琛岋級
ComboBox1.Top = DataGridView1.GetCellDisplayRectangle(DataGridView1.CurrentCell.ColumnIndex, DataGridView1.CurrentCell.RowIndex, True).Top
' 锛堜笂涓よ鏄竴琛岋紝鍙堕潰涓嶅锛屽啓浠g爜鏃惰鍐欏湪涓€琛岋級
ComboBox1.Text = DataGridView1.CurrentCell.Value '.ToString()
ComboBox1.Width = DataGridView1.GetCellDisplayRectangle(DataGridView1.CurrentCell.ColumnIndex, DataGridView1.CurrentCell.RowIndex, True).Width
'锛堜笂涓よ鏄竴琛岋紝鍙堕潰涓嶅锛屽啓浠g爜鏃惰鍐欏湪涓€琛岋級
ComboBox1.Visible = True
'Dim sp() As String = New String() {"1", "21", "30"}
' Dim installs() As String = New String() _
' {"Typical", "Compact", "Custom"}
' ComboBox1.Items.AddRange(installs)
ElseIf DataGridView1.CurrentCell.ColumnIndex = 3 Then
ComboBox1.DataSource = Nothing
ComboBox1.Items.Clear()
Dim ab As String() = New String() {"1", "2<", "3"}
ComboBox1.Items.AddRange(ab)
ComboBox1.Left = DataGridView1.GetCellDisplayRectangle(DataGridView1.CurrentCell.ColumnIndex, DataGridView1.CurrentCell.RowIndex, True).Left
'锛堜笂涓よ鏄竴琛岋紝鍙堕潰涓嶅锛屽啓浠g爜鏃惰鍐欏湪涓€琛岋級
ComboBox1.Top = DataGridView1.GetCellDisplayRectangle(DataGridView1.CurrentCell.ColumnIndex, DataGridView1.CurrentCell.RowIndex, True).Top
' 锛堜笂涓よ鏄竴琛岋紝鍙堕潰涓嶅锛屽啓浠g爜鏃惰鍐欏湪涓€琛岋級
ComboBox1.Text = DataGridView1.CurrentCell.Value '.ToString()
ComboBox1.Width = DataGridView1.GetCellDisplayRectangle(DataGridView1.CurrentCell.ColumnIndex, DataGridView1.CurrentCell.RowIndex, True).Width
'锛堜笂涓よ鏄竴琛岋紝鍙堕潰涓嶅锛屽啓浠g爜鏃惰鍐欏湪涓€琛岋級
ComboBox1.Visible = True
'Dim sp() As String = New String() {"1", "21", "30"}
' Dim installs() As String = New String() _
' {"Typical", "Compact", "Custom"}
' ComboBox1.Items.AddRange(installs)
Else
ComboBox1.Visible = False
ComboBox1.Width = 0
ComboBox1.DataSource = Nothing
ComboBox1.Items.Clear()
End If
End If
End Sub
Private Sub ComboBox1_SelectionChangeCommitted(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectionChangeCommitted
If DataGridView1.CurrentCell.ColumnIndex = 2 Then
DataGridView1.CurrentCell.Value = ComboBox1.SelectedValue
Else
DataGridView1.CurrentCell.Value = ComboBox1.SelectedItem
End If
End Sub