问题
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