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
AntonioRodrigoAsked:
Who is Participating?
 
CodeCruiserConnect With a Mentor Commented:
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
 
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
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.

All Courses

From novice to tech pro — start learning today.