ContextMenuStrip
で使用されているがありDataGridView
、DataGridViewはSplitContainer
パネル内にあります。私のユーザーは、グリッド内の任意の行を右クリックできるように要求しました。右クリックした行が選択された行になり、メニューが表示されます。SplitContainerパネル内にDataGridViewを配置するまで、私が作業してきたコード
private void DataGridView_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
// Get the row that was right-clicked on
DataGridView.HitTestInfo hitTestInfo = DataGridView.HitTest(e.X, e.Y);
if (hitTestInfo != DataGridView.HitTestInfo.Nowhere)
{
// Change the binding source position to the new row to 'select' it
BindingSource.CurrencyManager.Position = hitTestInfo.RowIndex;
}
}
}
最後の行に到達するまで、すべてが正常に機能しているようです
BindingSource.CurrencyManager.Position = hitTestInfo.RowIndex;
hitTestInfo.RowIndex
割り当てようとしている値が異なっていても、位置は常に-1のままです。これはSplitContainerパネルが原因でしょうか?もしそうなら、それを修正する方法について何か提案はありますか?
ありがとう