Is there an Event that fires when a control is fully constructed.

I have a custom control, derived from a ListView.
When the control is built, I want to do some work on the columns that are in the listview.
However, when I fire the method doing the work, at the end in the constructor, it can't find the columns yet.

Is there an event fired once the listview is completely built, that I could handle to do the work.

Thanks in advance :).
robleenheerAsked:
Who is Participating?
 
diwakarvermaCommented:
you can use HandleCreated event. It occurs when a handle is created for the control.

if you just wants to update the column property, you can use paint event but its performance.
0
 
DBAduck - Ben MillerPrincipal ConsultantCommented:
Are you data binding the custom control?  There is an OnItemDataBound and an OnItemCreated and then there is a Render event.

So depending on what you are trying to do with the listview, you can tap into the events that make sense for you.
0
 
robleenheerAuthor Commented:
HandleCreated for the (derived) listview apears to be firing before the columns are created.

this.Columns == null

returns true


I'm looking for an event that fires after all columns are created...... if there is one.

It's a bit like the 'Load' event in a form, whch fires after all controls in teh form have been added.
I'm looking for a 'Load' equivalent in ListView that fires after all Columns have been added.

No databinding
0
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.

 
Todd GerbertIT ConsultantCommented:
If you statically defined the columns (i.e. you added the columns using the properties window in the form designer), you should find that they're added inside the InitializeComponent() method in the .Designer.cs file for your user control, so they should be available any time after the call to InitializeComponent() in the constructor of your user control.
0
 
robleenheerAuthor Commented:
My previous comment is actually incorrect.
HandleCreated fires beautifully as I want it.

Thanks

0
 
robleenheerAuthor Commented:
Thanks
0
 
Todd GerbertIT ConsultantCommented:
Just be aware that it's possible for the HandleCreated event to be raised before there are any columns.
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.