logo

Custom Control property problem

Mehrdad posted on Friday, June 06, 2008 2:39 PM

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; }
}
-------------------------------
The class consists of a number of integer values.
Any idea?

Thanks in advance,
Mehrdad
reply


Custom Control property problem

Peter Duniho posted on Friday, June 06, 2008 2:48 PM

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
reply

Thank you for your response.

Mehrdad posted on Friday, June 06, 2008 3:13 PM

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
reply

Custom Control property problem

Peter Duniho posted on Friday, June 06, 2008 4:38 PM

Well, as has been suggested to you twice already, the Designer may not
show you the property unless it has a setter that can be used to set the
value.

However, in the end...just because you _need_ to do something, that
doesn't mean that the Designer will support that particular something.  I
appreciate your essay regarding how you want to use this property, but I
don't see how that's relevant with respect to whether the Designer will
work with that use.

I recommend you follow the advice that has been given to you and add a
setter for the property.  If that doesn't do the trick, then it's entirely
possible you can't do this, given the lack of suggestions other than that.

Pete
reply

No difference!!!

Mehrdad posted on Friday, June 06, 2008 4:44 PM

No difference!!!

Thanks,
Mehrdad
reply

Actually, the desiner shows the property in the "properties" window, but after

Mehrdad posted on Friday, June 06, 2008 5:07 PM

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
reply

Custom Control property problem

Peter Duniho posted on Friday, June 06, 2008 5:50 PM

Sorry to say, I'm not really sure what else you expected.  The Designer
can easily deal with properties of primitive types.  But I would expect
for complex types, it would have no way of knowing implicitly how to
construct instances of the classes you're dealing with.

I have seen hints that the Designer is actually quite flexible, and that
if you want some specific functionality, it's possible to _write_ special
handlers for particular data types you want.  But the scenario you're
talking about is something I'd be surprised to see handled automatically.

I could be wrong.  After all, you _are_ posting in the C# newsgroup.
There's random knowledge here about various .NET and VS topics, but it is
a language-specific newsgroup after all.  I recommend that, given no
specific descriptions of how to do this have been posted so far, you may
want to find a newsgroup that is more specific to the use of Visual
Studio, or even the Designer specifically.

Pete
reply

Custom Control property problem

parez posted on Sunday, June 08, 2008 4:19 AM

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

 

Didn't Find The Answer You Were Looking For?

View C# Posts   Ask A New Question

EggHeadCafe has experts online right now that may know the answer to your question.  We pay them a bonus for answering as many questions as they can.  So, why not help them and yourself by becoming a member (free) and ask them your question right now?
Create Account & Ask Question In Live Forum

Previous C# conversation.

.NET Distributed Applications    .NET Framework    ADO.NET    ASP.NET    ASP.NET Security    ASP.NET Web Controls    ASP.NET Web Services    .NET CLR    .NET Compact Framework    .NET Drawing GDI+    .NET COM Interop    .NET Performance    .NET Web Services    .NET Windows Forms    .NET WinForms Controls    .NET    C#    VB.NET    VC++.NET    .NET Security    Xml    Visual Studio .NET Debugging    Xml    Xsl    JScript    VBScript    WSH    Smart Phone Developer    VB COM    VB Controls    VB Crystal    VB DataBase ADO    VB Syntax    VB WinAPI    VC ATL    VC Debugger    VC Language    VC MFC    VC STL    Visio Developer VBA    WindowsCE Embedded VC    Powershell    .NET Microframework    VB Vista Compatibility    Deployment Server    .NET Microframework Porting   




  $1000    Adam Houldsworth - $181  |  Jonathan VH - $157  |  Kirtan Patel - $125  |  F Cali - $98  |  Mr. Khan - $92  |  more Neado  |  Free Icons  |  Privacy  |   (c) 2010