how do i alternate gridview selection from another form?

这一生的挚爱 提交于 2019-12-25 09:09:18

问题


hello i want to ask how do we alternate selection row grid view at main form from another form just using text box and button

the picture and code is in form 1

and form 2 lets say only got text box and button how do we can declare or use gridview data from form 1 in form 2 ?


回答1:


You could change Form2 so you can receive the gridView in the constructor :

public class Form2 : XtraForm
{
    private GridView grid;

    public Form2(GridView grid)
    {
        this.grid = grid;
    }

    private void somebutton_Click(object sender, EventArgs e)
    {
        grid.FocusedRowHandle = ...
    }
}

So when you open Form2 from Form1, you just send the gridView to the Form2 constructor :

someButtonOnForm1_Click(...)
{
    var form = new Form2(gridView1);
    form.Show(this);
}


来源:https://stackoverflow.com/questions/38455664/how-do-i-alternate-gridview-selection-from-another-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!