Gustavo

Gustavo

  • NA
  • 1.3k
  • 454.3k

How Do I: Change a DataGridView from a Class called?

May 13 2010 6:46 PM

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);

                    //.... A lot of other stuff is here.

       // 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 I would like to do something like this, but it does not recognize dataGridViewRecord.
//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;
// }
//}


Answers (1)