Datagridview鼠标单击行 [英] Datagridview mouse click on row

查看:63
本文介绍了Datagridview鼠标单击行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
当我单击按钮显示时,它将用我的数据填充数据网格.没问题.

Hello ALL,
When I click on button display it populates the datagrid with my data. No problem there.

private void btnDisplay_Click_1(object sender, EventArgs e)
{

        da.SelectCommand = new SqlCommand("SELECT FirstNum, SecondNum,  ThirdNum, FourthNum, FifthNum, Date FROM tblNUMBERS_1", cs);
        ds.Clear();
        da.Fill(ds);

        DataView dv = new DataView(ds.Tables[0], "Date = Date", "Date Desc", DataViewRowState.CurrentRows);
            dg.DataSource = dv;
            tblNUMBERSBS_1.DataSource = dv;
            dg.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
}



我可以浏览表中的记录.



I''m able to navigate through the records in the table.

private void btnNext_Click(object sender, EventArgs e)
{
    tblNUMBERSBS_1.MoveNext();
}



当我单击行时,说#8",它会根据需要选择整行.当我单击按钮移至下一个"时,它确实将其移至记录/第2行,而不是第9行.
实现此目标的最佳方法是什么?将其移至第9行?

tblNUMBERSBS_1是一个绑定源,是的.

BindingSource tblNUMBERSBS_1 = new BindingSource();



When I click on row lets say ''#8'' it does select the entire row as I want. When I click button ''Move Next'' it does move it to record/row #2 instead of row #9.
What is the best approach to achieve that? to move it to row #9?

tblNUMBERSBS_1 is a binding source, yes..


BindingSource tblNUMBERSBS_1 = new BindingSource();

推荐答案

它不起作用,因为您将DGV数据源设置为dv数据,并且将绑定源设置为相同的东西.当您只有一个时,您有两个独立的货币经理在起作用.

将绑定源设置为dv,然后将DGV数据源设置为绑定源.
It doesn''t work because you set the DGV DataSource to the dv data and you set the bindingsource to the same thing. You have two seperate currency managers in play here when you should have only one.

Set the bindingsource to dv then set the DGV Datasource to the bindingsource.


这篇关于Datagridview鼠标单击行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆