473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

C# Custom Event Question

Hi I am writing a custom tab control. I am capturing a caption property in a page which then changes the caption of the associated tab. (Similar to window's tab control).

I am using a delegate to capture the event of the change of the property and then I am changing the text value of the associated tab. The problem is that after I added the delegate code, I am unable to render the form in the designer. It's telling me that the 'Object reference not set to an instance of an object.'

The error is traced back to the InitializeComponent() where the user control attempts to set the default value on the caption property.

Here is the code snippets.

Error happens here:
Expand|Select|Wrap|Line Numbers
  1. this.tabPanelPageContainer1.Caption = "";
Property code:
Expand|Select|Wrap|Line Numbers
  1. public string Caption
  2.         {
  3.             get
  4.             {
  5.                 return _caption;
  6.             }
  7.             set
  8.             {
  9.                 _caption = value;
  10.                 OnCaptionChange(new PageEventArgs(_caption));
  11.             }
  12.         }
  13.  
Delegate Class
Expand|Select|Wrap|Line Numbers
  1. /// <summary>
  2.     /// Event arguments class for the page events
  3.     /// </summary>
  4.     public class PageEventArgs : EventArgs
  5.     {
  6.         private string _caption;
  7.  
  8.         public PageEventArgs(string caption)
  9.         {
  10.             _caption = caption;
  11.         }
  12.  
  13.         public string CaptionValue
  14.         {
  15.             get
  16.             {
  17.                 return _caption;
  18.             }
  19.         }
  20.     }
  21.  
Any idea why it's doing this?
Sep 17 '08 #1
2 1224
balabaster
797 Expert 512MB
I would hazard a guess that it's trying to assign a value to an object that technically doesn't exist yet. For instance - when you try and set the value in the initialize, it will fail because the object doesn't exist until the initialize phase is completed. Usually you would do stuff like this in the PreRender phase where you know the object exists...
Sep 17 '08 #2
I would hazard a guess that it's trying to assign a value to an object that technically doesn't exist yet. For instance - when you try and set the value in the initialize, it will fail because the object doesn't exist until the initialize phase is completed. Usually you would do stuff like this in the PreRender phase where you know the object exists...
Yeah, I am trying to get to the bottom of why the object is not being initialized but when I attach visual studio to the debugger and launch, it does not seem to be hitting the breakpoint set within the parent's InitializeComponent(). Any ideas on how else I can debug this issue?
Sep 17 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

21
by: One Handed Man \( OHM - Terry Burns \) | last post by:
When using a custom control. In order to check and see if values have changed one has to implement the IPostBackDataCollection interface. The values returned for the control seem to be simply a...
5
by: | last post by:
I am wondering what the best method of attaching custom Events to custom WebUserControls are. I cannot seem to find the proper terminology to expand my research. Basicallly I have a custom user...
3
by: Chris Newby | last post by:
I have a very simple custom control that derives from WebControls.Panel and implements INamingContainer. It appear that controls created as children of my custom control are having ViewState...
7
by: Girish | last post by:
OK.. phew. Playing with data grids for the past few days has been fun and a huge learning experience.. My problem. I have a requirement to display a gird with a gird. Within the embedded grid,...
2
by: Suzanne | last post by:
Hi all, I'm reposting this message as I'm experiencing this problem more and more frequently : I really hope someone out there can help me as I've been tearing my hair out on this one for a...
4
by: Jon Paal | last post by:
I have a custom server control which renders some html. I want to capture some interim values generated by the control as it processes the data. is there a way to capture and retrieve the...
0
by: Walter | last post by:
Hi, can someone please help me with my custom control viewstate problem....I haven't slept for hours trying to get this fixed. I am making two custom controls which will be included on a single...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
0
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Actually, my installer package is not for a Windows Service, but for a WinForms application. Well, it is kind of both: this is a multi-project solution with its main target being a WinForms...
4
by: =?Utf-8?B?UmljaEI=?= | last post by:
I am trying to create a project using the ASP.NET AJAX accordion control. I would like to dynamically add panes to the control with a form template added when the pane is added. I have tried...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.