Hello:
I have a DataGridView that I have to update. Here is my issue:
I have a MDIParent called FormICEPack. The other two MDIChild are called FormLocation and FormProduct. I have more forms, but I just want to do these two and then, it should work for the other forms.
In the MDIChild FormLocation I do a: ClassControl ClassControl = new ClassControl(this);
which will add TextBoxEnter and TextBoxLeave routines. The TextBoxEnter in the ClassControl is:
TheControl.Enter += new EventHandler(TextBoxEnter);
TheControl.Leave += new EventHandler(TextBoxLeave);
TheControl.MouseHover += new EventHandler(TextBoxMouseHover);
TheControl.MouseLeave += new EventHandler(TextBoxMouseLeave);
All is working like I want it to.
However: I need to update the DataGridView that is in the MDIChild FormLocation when the TextBox is changed, which is controlled by the ClassControl.
private void TextBoxLeave(object sender, EventArgs e)
{
PriorColor = ((TextBox)sender).BackColor;
((TextBox)sender).BackColor = LeaveColorOriginal;
TheField_ID = ((TextBox)sender).Name;
TheField_ID = TheField_ID.Substring(7);
TheValue = ((TextBox)sender).Text;
ClassValidate.Hint(TheForm_ID, TheFile_ID, TheField_ID, TheValue);
// HERE ADD LOGIC TO UPDATE DATAGRIDVIEW
}
So, question is: How can I change the DataGridView in the FormLocation and keep the logic in the ClassControl? (Confusing?)
In the // HERE ADD LOGIC TO UPDATE DATAGRIDVIEW
//for (int i = 0; i < dataGridViewRecord.RowCount - 1; i++)
//{
// if (dataGridViewRecord.Rows[i].Cells["Column"].Value.ToString() == TheField_ID)
// {
// dataGridViewRecord.Rows[i].Cells["TheValue"].Value = TheValue;
// }
//}
Hector Hugo Alpizar CesenaPosted May 28, 2010, 7:50 PM
This sample is windows form with a grid view push button 1 and the same grid will appear in the windows form number 2. Push the button in the windows number two and the grid will be back in the windows form number 1
Greetings