Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form1_Load getting fired after DataGridView1_RowsAdded

Status
Not open for further replies.

Plato2

Programmer
Dec 6, 2002
192
0
0
US
My vb.net form has DataGridView component and my component has event DataGridView1_RowsAdded. But when my form gets loaded the event DataGridView1_RowsAdded gets fired first and then Form1_Load event...
Does any body know why is this?How can I change it?

Thanks in advance
 
I don't know why but maybe it's because the datagrid is initialised before the form.load event is fired. Because InitialiseComponents occurs before load.

An unformal way to control what happens when the DataGridView1_RowsAdded event is fired is to have a private boolean variable (let's call it myFlag). This variable will be set to True (myFlag = True) in the form_load event handler. In the DataGridView1_RowsAdded event handler you could have something like:

Code:
if myFlag then
'the job you want to get done here
end if
 
Depends on where you fill the DataGrid.
If it's in the
Code:
Public Sub New()
 'DataGrid got filled here
 'or a procedure filling the DataGrid called
End Sub

Or a public procedure gets fired before the
.Show() or .ShowDialog().

Then the Form1_Load event comes later.

Regards,
mansii
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top