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

DataGridView load event

Hello,

I am using Windows forms. I have a DataGridView on my form. I need to hook up the event which occurs on initialization of DataGridView. I know that I can catch event from my form (on which DataGridView is placed), but I can't to this, because I have several DataGridViews on my form and I need to operate on columns of each of them.

I thought of catching the parents Load event of DataGridView, which is System.Windows.Forms.Control class, but I don't know how to do this? Any idea?

Greetings, Frenky
0
AntonioRodrigo
Asked:
AntonioRodrigo
  • 2
1 Solution
 
jppintoCommented:
0
 
AntonioRodrigoAuthor Commented:
Thanks for answer - but Paint event is triggered multiple times (f.e. if you minimize control and then maximize it back again). I need an event which is triggered only once - at control initializing.
0
 
jppintoCommented:
I don't any other then using the Form.Load event...
0
 
CodeCruiserCommented:
You mean you want to execute same code against each datagridview?

You can use a single event handler with all the grids. For example

Form_Load

AddHandler dgv1.DataSourceChanged, Addressof MyHandler
AddHandler dgv2.DataSourceChanged, Addressof MyHandler
...


Then in the event, you can use sender object to determine which grid raised the event.

http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.datasourcechanged.aspx
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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