2009-11-16 180 views
1

使用VB.Net,我有一个DataGridView与组合框列。用户在ComboBox中更改选区时甚至可以使用该选项?然后进行测试 -DataGridView&ComboBox事件?

+1

另请考虑填写您的个​​人资料,以便我们可以给您打电话给除“未知”以外的内容。您的个人资料在这里:http://stackoverflow.com/users/198155/unknown-google – 2009-11-16 05:29:48

回答

1

在Grid.Item.FormatedValue,而不是价值

0

.FormatedValue为当前单元格在您关注的列中。

+0

这是一条评论或答案?如果只是评论,请考虑编辑您的答案。 – 2011-06-26 18:59:37

2

您可以在此事件,当组合框的值已被选定...

Private Sub dataGridView_EditingControlShowing(ByVal sender As Object, ByVal e As DataGridViewEditingControlShowingEventArgs) 
    Try 
     If (Me.dataGridView.CurrentCell.ColumnIndex = CType(Column.Col,Integer)) Then 
      Dim comboBox As ComboBox = CType(e.Control,ComboBox) 
      If (Not (comboBox) Is Nothing) Then 
       AddHandler comboBox.SelectedIndexChanged, AddressOf Me.ComboBoxIndexChanged 
      End If 
     End If 
     Return 
    Catch Ex As Exception 
     Utils.ErrMsg(Ex.Message) 
     Return 
    End Try 
End Sub 
0

CurrentCellDirtyStateChanged SelectedValueChanged