Cannot access parent

2 posts, 0 answers
  1. Mohamed
    Mohamed avatar
    1 posts
    Member since:
    Feb 2014

    Posted 10 Feb 2014 Link to this post

    I'm new to Rad controls and i'm having a problem accessing the parent radfrom of a child on (MDI not enabled). would appreciate the assistance.

    in the parent form when i click a button it does this:

    frmAddExtraItem fax = new frmAddExtraItem();


    and it shows the child form, but when i click a button in the child form the code is this:


    now datagridview1 is public, but this.ParentForm is always null, i tried all combinations possible for both code snippets, trying this.Parent, and even this.Parent.Parent multiple times, and also in the first code i tried fax.ParentForm = this, fax.Parent = this, and fax.Parent = this.Parent, and so on many combinations including fax.ShowDialog(), but nothing seems to work and i always get this.Parent or this.ParentForm as null, how can i access the dtatagridview1 in the parent in that case?

    thank you
  2. Dimitar
    Dimitar avatar
    1936 posts

    Posted 12 Feb 2014 Link to this post

    Hi Mohamed,

    Your question has already been answered in the other thread you've opened. 

    I am adding the answer here in order the community to benefit from it:

    You can use the Owner property to get the corresponding grid:
    private void radButton1_Click(object sender, EventArgs e)
        RadGridView grid = ((Form1)this.Owner).RadGridView1;

    I hope this helps. 


    Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).

Back to Top