2011-02-18 30 views

回答

5

您可以使用:

var value = DataGridView.Rows[0].Cells[0].Value 

注意:您會提供正確的行和手機號碼。

,或者如果它綁定到一個對象像列表項

string value = DataGridView.Rows[RowIndex].Cells[ColumnIndex].Value.ToString(); 

if DataGridView.Rows[RowIndex].Cells[ColumnIndex] is DataGridViewComboBoxCell && !string.IsNullOrEmpty(value)) 
{ 
    List<ListItem> items = ((DataGridViewComboBoxCellDataGridView.Rows[RowIndex].Cells[e.ColumnIndex]).Items.Cast<ListItem>().ToList(); 
    ListItem item = items.Find(i => i.Value.Equals(value)); 
} 
+0

我嘗試在CellContentClick事件,但沒有成功讀取它,你可以做這樣的事情。如何在選定的值更改後讀取它。 – Dusan 2011-02-18 13:22:44