我有一个充满了客户的DataSet.我想知道是否有任何方法来过滤数据集,只获取我想要的信息.例如,为了获得CostumerName和CostumerAddress拥有的客户CostumerID = 1
可能吗?
我有一个datagridview,我在其中显示有关产品的信息.我想在用户选择一个单元格然后右键单击该单元格时绑定一个上下文菜单.我有另一个contextmenu,并且一个绑定到datagridview的列.如果用户右键单击上下文菜单显示的列.
我试过这样但是不起作用.上下文菜单显示用户右键单击单元格的时间,但绑定到列标题的上下文菜单不起作用.
private void GridView1_CellMouseUp(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
productContextMenu.Show(GridView1, e.Location);
}
}
Run Code Online (Sandbox Code Playgroud)
如何在用户右键单击datagridview时显示?
很多人提前.
编辑
Thnx的答案.我解决了这个问题:
private void GridView1_MouseUp(object sender, MouseEventArgs e)
{
DataGridView.HitTestInfo hitTestInfo;
if (e.Button == MouseButtons.Right)
{
hitTestInfo = GridView1.HitTest(e.X, e.Y);
if (hitTestInfo.Type == DataGridViewHitTestType.Cell)
{
productContextMenu.Show(GridView1, e.Location);
}
}
}
Run Code Online (Sandbox Code Playgroud)
上下文都显示了.当我单击上下文菜单显示的列时,以及单击上下文菜单显示的单元格时.
我有一个填充了产品信息的DataGridView.datagridview共有50列,但用户并不总是需要所有列,我想帮助他们选择要显示的列和不显示的列.
我想编程的一个解决方案是,当用户右键单击列时,他们可以从弹出的列表中选择要显示哪些列以及哪些列不是shos.就像下面的图片一样.

我怎样才能做到这一点.我真的很感激任何帮助.