Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wiring Events

Status
Not open for further replies.

ChewDoggie

Programmer
Mar 14, 2005
604
US
G'morning All,

I have, in the past, been able to wire up events in an MDIParent Form with the following code:

Code:
        private void smnuCheckin_Click( object sender, EventArgs e )
            {
            frmCheckin = new CheckInItem(); // create new frmChecking object
            frmCheckin.MdiParent = this; // set mdiparent
            frmCheckin.Show(); // show the form
            [COLOR=red]frmCheckin.FormClosing += new System.Windows.Forms.FormClosingEventHandler( onFormClosing );[/color]
            smnuCheckin.Enabled = false;
            }

        private void onFormClosing( object sender, System.Windows.Forms.FormClosingEventArgs e )
            {
            if ( sender.ToString().Contains( "Juvenile" ) )
                {
                smnuChild.Enabled = true;
                }
            else if ( sender.ToString().Contains( "Check-In" ) )
                {
                smnuCheckin.Enabled = true;
                }
            else if ( sender.ToString().Contains( "Check-Out" ) )
                {
                smnuCheckout.Enabled = true;
                }
            else if ( sender.ToString().Contains( "Add Item" ) )
                {
                smnuAddItem.Enabled = true;
                }
            else if ( sender.ToString().Contains( "About" ) )
                {
                mnuAbout.Enabled = true;
                }
            else
                {
                smnuAdult.Enabled = true;
                }
            }

So that when the Child Form in question is closing, the "onFormClosing" (in the MDIParent) code executes. And it works.

Now, I'd like to execute some code on the MDIParent when a row is selected on a DataGridView on a Child Form. I've tried the following code but it keeps complaining:

Code:
        private void ssmnuCompanySelect_Click(object sender, System.EventArgs e)
            {
            Company = new frmCompany();
            Company.MdiParent = this;
            Company.Show();
            [COLOR=red]Company.dgAssociates.RowEnter += new DataGridViewCellEventArgs(onGridClicking);[/color]
            }

        private void onGridClicking(object sender, DataGridViewCellEventArgs e)
            {
            if (sender.ToString().Contains("Select Associate"))
                {
                lblStatusStrip.Text = string.Format("{0} {1} ({2})", AssocFName, AssocLName, AssocID);
                }
            }

The Error is: "DataGridViewCellEventArgs does not contain a constructor that takes '1' argument".

I don't understand why the first code snippet executes OK and the second code snippet doesn't.

BTW...the access modifier for dgAssociates was changed to "public".

If someone could enlighten me and point me in the right direction, that'd be great.

Chew

10% of your life is what happens to you. 90% of your life is how you deal with it.
 
look at the type DataGridViewCellEventArgs is the event arguments, not the event handler.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
DOH !

Good eye, Jason. Thank you !

Chew

10% of your life is what happens to you. 90% of your life is how you deal with it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top