私は別のボタンからdatagridviewセルイベントメソッドを呼び出そうとしています。Datagridviewセルのダブルクリックイベントをボタンから呼び出す方法は?
DataGridViewのセルをダブルこれは私が
0123を受信しています、私はこの方法Error 3 The type or namespace name 'DataGridViewCellEventHandler' does not exist in the namespace 'System' (are you missing an assembly reference?) C:\VisualC#\Projects\DataGridViewApplication\DataGridViewApplication\List.Designer.cs 340 46 DataGridViewApplication
private void button6_Click(object sender, EventArgs e)
{
ListDataGridView_CellDoubleClick(sender, e);
}
エラー呼んでいるボタンである方法
private void ListDataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex >= 0)
{
ListDataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
DataGridViewRow row = this.ListDataGridView.Rows[e.RowIndex];
comboBox2.Text = row.Cells[1].Value.ToString();
}
}
をクリックします
私がしたこと:
EventArgsをDataGridViewCellEventArgsに変更しました。
private void button6_Click(object sender, DataGridViewCellEventArgs e)
{
ListDataGridView_CellDoubleClick(sender, e);
}
は今、私はエラーを受信しています:
this.button6.Click += new System.EventHandler(this.button6_Click);
Error 3 No overload for 'button6_Click' matches delegate 'System.EventHandler'
C:\VisualC#\Projects\DataGridViewApplication\DataGridViewApplication\List.Designer.cs 340 35 DataGridViewApplication
は今、私はまだここにこのエラーを受信し、stuckedこの
this.button6.Click += new System.DataGridViewCellEventHandler(this.button6_Click);
にボタンイベントハンドラのコードを変更しました
Error 3 No overload for 'button6_Click' matches delegate 'System.EventHandler'
ここに解決策を見つけた: How to call a datagridview event with a click of a button?
private void button6_Click(object sender, EventArgs e)
{
ListDataGridView_CellDoubleClick(null, null);
}
をしかし、これは私のために働いていない、それは私にエラーを与えます。
Object Reference not set to an instance of an object.
、あなたはDoSomething''のような方法でロジックを入れて、 'CellDoubleClick'イベントや、ボタンの' Click'イベントの両方でそれを呼び出すことができます。たとえば、[this post](http://stackoverflow.com/a/38611739/3110834)を見てください。 –