Form Size

Posted on 2006-03-27
Last Modified: 2010-04-16

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 ??

Question by:Vik Shah
    LVL 30

    Expert Comment

    by:Alexandre Simões
    So you don't want to have any scroll bars on the GridView control?
    LVL 21

    Expert Comment

    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,
    LVL 30

    Accepted Solution

    Try not to reinvet the wheel...
    Users are used to have grids with scrollbars on every other applications.

    wouldn't it be worst if the resizing of the window would make it bigger than the screen bounds?

    Thank about it.

    Alex :p
    LVL 10

    Expert Comment

    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

    Author Comment

    by:Vik Shah
    seems that all of them suggest to have scrollbar.
    so I think I have to use the scrollbar.

    and as of the'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
    LVL 21

    Expert Comment

    I have the same time for Alex and myself - there is the split points option for your future reference...

    Author Comment

    by:Vik Shah
    Thank you for telling me about the split point...
    I didn't know that before..

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    745 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now