Solved

GET RELATIVE CONTROL POSITION TO FORM SIZE

Posted on 2011-02-13
13
462 Views
Last Modified: 2012-05-11
Hi All,

I have a windows form.

1. Datagridview.
2. Flowlayoutpanel.

The form is set to maximize.

I want resize the datagridview control height from 0 to Flowlayoutpanel top location (relative to form).

How could I do it ?

Thank you.

0
Comment
Question by:emi_sastra
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
13 Comments
 
LVL 11

Expert Comment

by:Deepak Lakkad
ID: 34882964
Hi,

You can use following code to set width of DataGridView when form is resized.

    Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
        DataGridView1.Width = FlowLayoutPanel1.Width
    End Sub

Open in new window


Same way you can set height of the DGV

- Deepak Lakkad
0
 
LVL 1

Author Comment

by:emi_sastra
ID: 34882995
Hi deepaklakkad,

I don't want to set them at the same size.

I want to set the Datagridview height from 0 to FlowLayoutPanel1 relative top position to screen.

For example screen size = 1024 x 768

FlowLayoutPanel1.top  is at  1000 (this is relative position to form size), thus I want Datagridview.heigth = 990.

Thank you.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 34883150
Select the FlowLayoutPanel and set its Dock property to Bottom.  Now adjust its Height in the Size property to the correct amount.

Now select the DataGridView and set its Dock property to Fill.
0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
LVL 1

Author Comment

by:emi_sastra
ID: 34883158
Hi Idle_Mind,

I have tried it like you said.
The DataGridView size cross the FlowLayoutPanel  area.

Thank you.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 34883179
Docking is very finicky and sometimes cannot be "undone" when it has been done "out of order".  You need to add the FlowLayoutPanel and set its Dock to Bottom FIRST.

This may require you start with a BRAND NEW Form and add the FlowLayoutPanel and set Dock before you do the same with the DataGridView.
0
 
LVL 1

Author Comment

by:emi_sastra
ID: 34883193
I've done at design time.
I also set anchor all direction to DataGridView

Thank you.
0
 
LVL 1

Author Comment

by:emi_sastra
ID: 34885127
I meant still DataGridView size cross the FlowLayoutPanel  area.

Thank you.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 34885296
Did you try by starting with a NEW form and then adding the FlowLayoutPanel FIRST?
0
 
LVL 1

Author Comment

by:emi_sastra
ID: 34885308
I don't do that, since I have put it at design time.

Thank you.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 34885321
I understand that.  The Dock property gets confused easily and you can't reliably change the "order" of docked items.

What I'm proposing is that you RECREATE the Form (at design-time) and be sure to add and dock the FlowLayoutPanel before the DataGridView.
0
 
LVL 1

Author Comment

by:emi_sastra
ID: 34885364
Another problem is have also a FlowLayoutPanel (flp2) at the right side (vertical box).
When I dock flp1 to bottom, then it also cross the flp2 ?

Thank you.
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 34885478
If you don't want it to cross FLP2 then you have to dock FLP2 first.

So the order of adding & docking would be:
(1) FLP2 Docked to the Right
(2) FLP1 Docked to the Bottom
(3) DataGridView Docked Fill

A picture showing the desired layout would be helpful.
*Sometimes you can't achieve the desired layout with only anchor/dock.  In those cases you may need to employ the TABLELAYOUTPANEL to get finer control over how things are positioned relative to each other.
0
 
LVL 1

Author Comment

by:emi_sastra
ID: 34885614
Ok. It works.

Thank you very much for your help.

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Code enhancement 4 44
VB.NET Application Installation with sqlserver 8 67
how to remove error in database 6 53
EMAIL RANGES BASED ON CURRENT TIME 12 31
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question