-
July 6th, 2020, 01:13 PM
#1
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
-
July 7th, 2020, 03:30 AM
#2
Re: Form on the form
You have a typo in the last code snippet. Shouldn't it be frmCoordinator, not Coordinator?
-
July 7th, 2020, 07:34 AM
#3
Re: Form on the form
Originally Posted by Arjay
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
-
July 7th, 2020, 05:21 PM
#4
Re: Form on the form
Originally Posted by chapran
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|