私はC#でWindowsアプリケーションを作成しています。グリッドビューセルのクリックでグリッドビューからチェックリストボックスに値を取得したいのですが、チェックボックスで値がチェックされています..
質問する
303 次
1 に答える
0
これを試して 、
private void yourGrid_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (yourGrid.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null)
{
yourCheckListBox.Items.Add(yourGrid.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString());
}
}
ここで checkBoxList にデータを追加する方法を参照できます。
またはこれを試してください、
private void yourGrid_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (yourGrid.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null)
{
string selectedValue =yourGrid.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
yourCheckListBox.Items.Add(new BindingList<Binder> { new Binder { Name = selectedValue } });
yourCheckListBox.Invalidate();
yourCheckListBox.Update();
yourCheckListBox.Refresh();
}
}
于 2013-05-31T10:22:15.317 に答える