CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2013
    Posts
    90

    Form on the form

    I'm trying to implement VB.Net scenario in C#.
    In VB.Net I have an MDI application with MDI form and several child forms.
    MDI has a List Bar control on the left.
    Child forms load and occupying the entire client area of MDI.
    On of the child form (frmCoordinator) may load another form (frmBidCalendar) and that form should have exact the same size and location as the caller.
    There is the code in the frmBidCalendar_Load:
    Code:
            Dim rectCaller As Rectangle
            Dim rectLocation As Rectangle
            Try
                rectCaller = frmCoordinator.ClientRectangle
                rectLocation = frmCoordinator.RectangleToScreen(rectLocation)
    
                Me.Size = rectCaller.Size
                Me.Location = rectLocation.Location
    I tried this in C#:
    Code:
                    rectCaller = frmCoordinator.ClientRectangle();
    and it says 'The name frmCoordinator doesn't exist in the current contents'
    I tried this:
    Code:
                    rectCaller = Coordinator.ClientRectangle;
    and it says 'An object reference is required...'
    How can I translate VB.Net code to C#?

    Thank you

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Form on the form

    You have a typo in the last code snippet. Shouldn't it be frmCoordinator, not Coordinator?

  3. #3
    Join Date
    Jan 2013
    Posts
    90

    Re: Form on the form

    Quote Originally Posted by Arjay View Post
    You have a typo in the last code snippet. Shouldn't it be frmCoordinator, not Coordinator?
    The previous attempt has frm, the last one is correct, no typo.
    Thank you

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Form on the form

    Quote Originally Posted by chapran View Post
    The previous attempt has frm, the last one is correct, no typo.
    Thank you
    Is frmCoordinator.ClientRectangle a property or a method? If it is a property it should nit be called with parentheses.

    Try
    rectCaller = frmCoordinator.ClientRectangle;
    Not
    rectCaller = frmCoordinator.ClientRectangle();

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured