Link to home
Start Free TrialLog in
Avatar of Vik Shah
Vik ShahFlag for United States of America

asked on

Form Size

hi

I have a program which return some data as DataTable
then I put the DataTable in the DataGridView
and the view is added to the Form for display
the problem is :
the DataTable returned  have different rows each time, so the height is different
how can I set the form to expand the form size automatically ??

thanks
 
Avatar of Alexandre Simões
Alexandre Simões
Flag of Switzerland image

So you don't want to have any scroll bars on the GridView control?
I would advise you against doint it - what size the form are you going to set for 2000 rows?? I'd rather have a scrollbar, which is a default option for a datagrid. You're talking about adding DataGridView to the form, I'd suggest it's in 2005, as it's not an option in 2003. There would be a scroll bar for that one as well i suggest.

good luck,
yurich
ASKER CERTIFIED SOLUTION
Avatar of Alexandre Simões
Alexandre Simões
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I would suggest scroll bars too, but maybe you know you only will have about 10 rows or something so here goes the code to resize the form:

put this line in the form code where you get the Nr of rows:

this.Size = new Size(Width, Height);

Width of course is the width of the form, end height..yes you know :)

u can calculate the height by for example NrofRows * (heighth of row) +EverythingButTheRowsConstantHeight
Avatar of Vik Shah

ASKER

seems that all of them suggest to have scrollbar.
so I think I have to use the scrollbar.

and as of the points..it's hard to decide who should I give it to...
since AlexCode is the first one response, so I would give it to him...
hope Yurich and dkloeck don't mind
I have the same time for Alex and myself - there is the split points option for your future reference...
Yurich
Thank you for telling me about the split point...
I didn't know that before..