[Last Call] Learn how to a build a cloud-first strategyRegister Now


Finding if the form is loaded

Posted on 2007-07-27
Medium Priority
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
  • 2
LVL 20

Expert Comment

ID: 19581991
Can you post a snippet of your code?

LVL 18

Expert Comment

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


Author Comment

ID: 19582173
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

Priest04 earned 2000 total points
ID: 19582279
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

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

829 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