.net sukbir

Dear All,

My problem here is that I have main form with a grid. I have set the modifiers for the grid to be public. So I have text box which upon entering the data it will add a new line to the grid. But if the text box value is below a certain value. I will pop up another separate pop up form where the user will do validation using his password. Then upon validation in this form I would like to update the grid in my main form. How can I reference the main form grid in the pop-up form and edit its value. Thanks



Re: Windows Forms General Updating parent grid based on the pop up form confirmation

nobugz

Pass either the grid or the form reference to the constructor of your dialog form. For example:

public partial class Form2 : Form {
private DataGridView mGrid;
public Form2(DataGridView grid) {
InitializeComponent();
mGrid = grid;
}
}

And in the form with the grid:
Form2 f2 = new Form2(dataGridView1);
f2.ShowDialog(this);

You can now freely reference the grid through the mGrid member in your dialog. And you can keep the grid control private.





Re: Windows Forms General Updating parent grid based on the pop up form confirmation

.net sukbir

Dear Noubugz,

Thanks for your kind answer it works well. What do you mean by keeing the grid control private. Another question is that upon completing my pop-up form shall I use the command this.close() to close my form Upon closing my pop-up form I will go back to my main form. So once I am back to my main form I would like the text box to be invisible How can I do this Thanks.





Re: Windows Forms General Updating parent grid based on the pop up form confirmation

nobugz

You can keep the control's Modifiers property set to Private. If you reference the grid in your dialog through a form reference, you would have to set it to Public. Close the dialog by assigning the this.DialogResult property. I don't understand your textbox question, start a new thread.





Re: Windows Forms General Updating parent grid based on the pop up form confirmation

.net sukbir

Dear Nobugz,

I do understand about the private and public because if it is set as private then you cant edit it from other places. Where must I place the code this.DialogResult Ok I will start a new thre on the text box. Thanks.