• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 195
  • Last Modified:

Finding if the form is loaded

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?
0
rajesh_khater
Asked:
rajesh_khater
  • 2
1 Solution
 
REA_ANDREWCommented:
Can you post a snippet of your code?

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

Goran
0
 
rajesh_khaterAuthor Commented:
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:
http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_22698846.html
0
 
Priest04Commented:
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;

Goran
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now