Solved

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

Posted on 2011-02-18
7
307 Views
Last Modified: 2013-12-17
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 :).
0
Comment
Question by:robleenheer
7 Comments
 
LVL 1

Accepted Solution

by:
diwakarverma earned 250 total points
ID: 34926398
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
 
LVL 24

Expert Comment

by:DBAduck - Ben Miller
ID: 34926483
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
 

Author Comment

by:robleenheer
ID: 34930861
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 34930966
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
 

Author Comment

by:robleenheer
ID: 34930969
My previous comment is actually incorrect.
HandleCreated fires beautifully as I want it.

Thanks

0
 

Author Closing Comment

by:robleenheer
ID: 34930974
Thanks
0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 34930996
Just be aware that it's possible for the HandleCreated event to be raised before there are any columns.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now