Custom Control property problem

M

Mehrdad

When I put any component on a form, all of the initial values of the
components properties are collected in a auto created private method named
InitializeComponent. like this:
----------------------------------------------
this.button1.Location = new System.Drawing.Point(66, 279);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
-------------------------------------------------------------------
When I put my own control, all of its properties are added into the
InitializeComponent methode except the GraphInfo class which I defined it as
a property using the below code:
-------------------------------
[Category("Graph")]
[Browsable(true)]
public List<GraphInfo> Graphs
{
get { return this.graphs; }
}
#endregion
-------------------------------
The class consists of a number of integer values.
Any idea?

Thanks in advance,
Mehrdad
 
M

Mehrdad

Thank you for your response. Accually, as a part of a project, I need to
build a specific histogram (control) which can support multiple graphs. The
GraphInfo class contains all of the information for the each indivisual
graph and I need to define it as a dynamic array property to support
unlimited number of graphs.

Thank you again,
Mehrdad



Peter Duniho said:
[...]
When I put my own control, all of its properties are added into the
InitializeComponent methode except the GraphInfo class which I defined
it as
a property using the below code:
-------------------------------
[Category("Graph")]
[Browsable(true)]
public List<GraphInfo> Graphs
{
get { return this.graphs; }
}
#endregion

Are you sure that the Designer supports that?

I admit, I use the Designer in only the most rudimentary ways most of the
time, so I'm not familiar with the exact details for stuff like this. But
it's not surprising to me at all that the Designer might ignore a property
that's a List<> of some arbitrary class you've defined, at least by
default.

It's _possible_ there's some way to write some sort of plug-in component
for the Designer that would handle this. But otherwise, I'm not sure what
you expect the Designer to do with that. What sort of UI would it present
to the user for initialization of this arbitrary collection?

Pete
 
P

parez

When I put any component on a form, all of the initial values of the
components properties are collected in a auto created private method named
InitializeComponent. like this:
----------------------------------------------
this.button1.Location = new System.Drawing.Point(66, 279);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
-------------------------------------------------------------------
When I put my own control, all of its properties are added into the
InitializeComponent methode except the GraphInfo class which I defined it as
a property using the below code:
-------------------------------
[Category("Graph")]
[Browsable(true)]
public List<GraphInfo> Graphs
{
get { return this.graphs; }}

#endregion
-------------------------------
The class consists of a number of integer values.
Any idea?

Thanks in advance,
Mehrdad

Just taking shot here.. try adding a set property and see what
happens..
 
M

Mehrdad

No difference!!!

Thanks,
Mehrdad


parez said:
When I put any component on a form, all of the initial values of the
components properties are collected in a auto created private method
named
InitializeComponent. like this:
----------------------------------------------
this.button1.Location = new System.Drawing.Point(66, 279);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
-------------------------------------------------------------------
When I put my own control, all of its properties are added into the
InitializeComponent methode except the GraphInfo class which I defined it
as
a property using the below code:
-------------------------------
[Category("Graph")]
[Browsable(true)]
public List<GraphInfo> Graphs
{
get { return this.graphs; }}

#endregion
-------------------------------
The class consists of a number of integer values.
Any idea?

Thanks in advance,
Mehrdad

Just taking shot here.. try adding a set property and see what
happens..
 
M

Mehrdad

Actually, the desiner shows the property in the "properties" window, but
after adding some graphs in the collection, non of the graphs info is saved
in the InitializeComponent methode, so, by closing and reopening the VS2008,
all of the graphs info are removed from the collection!!!

Thanks,
Mehrdad
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top