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

Posted on 2011-02-18
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 :).
Question by:robleenheer
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

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.
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.

Author Comment

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
Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

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.

Author Comment

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



Author Closing Comment

ID: 34930974
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.

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
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 is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

687 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