d DataGridView( dgvHardwareという名前)コントロールを備えた基本的なWinFormsアプリがあり、このコントロールにバインドされているのは次のコードです。
private void dgvHardware_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
if (e.Control is ComboBox)
{
((ComboBox)e.Control).SelectionChangeCommitted -= new EventHandler(cboDgvHardware_SelectionChanged);
((ComboBox)e.Control).SelectionChangeCommitted += new EventHandler(cboDgvHardware_SelectionChanged);
}
}
private void cboDgvHardware_SelectionChanged(object sender, EventArgs e)
{
// string result is the selected text of the combo box
// int row is the row index that the selected combo box lives
string result = ((ComboBox)sender).SelectedItem.ToString();
// int row = ????
}
簡単に言うと、ComboBoxの選択に基づいて行内の他のセルを変更するには、イベントが発生している行を判別できる必要があります。2番目の関数の結果は、その価値に対して正しい値を返します。
これが不明な場合、または追加情報が必要な場合はお知らせください。
ありがとう、
アンドリュー