Finding if the form is loaded

Posted on 2007-07-27
Last Modified: 2010-04-15
I am starting a form in Maximized mode.
The Form Resize event is getting fired before the Form Load event.
In the Form Resize event, I am resizing a DataGridView. but I get an error that row index is out of bounds.

What is the best way to trigger the resize code after the form is fully loaded?

I know I can keep a flag in Form Loaded and set it to true. Is there any other way?
Question by:rajesh_khater
    LVL 20

    Expert Comment

    Can you post a snippet of your code?

    LVL 18

    Expert Comment

    Why do you use Rowindex at all in Resize event? You should resize DataGrdiView's height, and width, and if necessary, Columns height.

    LVL 1

    Author Comment

    I need to coz I want the grid's Height to be only as much as not to have any partially visible rows.

    The code I am using is from:
    LVL 18

    Accepted Solution

    Must be the error is caused by this line

    int rowHeight = dgv.Rows[0].Height;

    If so, then just check for thr RowCound

    if (dgv.RowCount == 0) return;


    Featured Post

    Hire Top Freelancers to Complete C# Projects

    Source the talented Expert Exchange community
    for top quality work on your C# projects.

    Hire the best. Collaborate easily. Get quality work.

    Join & Write a Comment

    This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    728 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

    19 Experts available now in Live!

    Get 1:1 Help Now