.NET Framework - Custom Control property problem
Asked By Mehrdad
06-Jun-08 02: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
Visual Studio
(1)
System.Drawing.Point
(1)
System.EventHandler
(1)
EventHandler
(1)
Control
(1)
InitializeComponent
(1)
GraphInfo
(1)
Click
(1)
Peter Duniho replied...
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
Mehrdad replied...
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
parez replied...
Just taking shot here.. try adding a set property and see what
happens..
Peter Duniho replied...
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
Mehrdad replied...
No difference!!!
Thanks,
Mehrdad
Mehrdad replied...
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
Peter Duniho replied...
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
problem? It would be too much work to completely rewrite the application. Zach. C# Discussions Visual Studio (1) ComponentResourceManager (1) ContentAlignment (1) GraphicsUnit (1) EventHandler (1) FontStyle (1) CheckBox (1) TextBox (1 Drawing.Color.GhostWhite; this.textBox17.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.textBox17.Location = new System.Drawing.Point(520, 426); this.textBox17.MaxLength = 5; this.textBox17.Name = "textBox17"; this.textBox17.Size = new System Drawing.Color.GhostWhite; this.textBox15.BorderStyle = System.Windows.Forms.BorderStyle.None; this.textBox15.Location = new System.Drawing.Point(-32, 12); this.textBox15.Multiline = true; this.textBox15.Name = "textBox15"; this.textBox15.ScrollBars = System.Windows
Framework Hello, I currently fight with a problem during the derivative of WinForm controls. In Visual Studio I created a new User Control. This control is derived from the DataGridView of the baseDataGrid1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.baseDataGrid1.Enabled = false; this.baseDataGrid1.Location = new System.Drawing.Point(358, 88); this.baseDataGrid1.Name = "baseDataGrid1"; this.baseDataGrid1.Size = new System.Drawing.Size(240, 150 property to true: this.baseDataGrid1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.baseDataGrid1.Location = new System.Drawing.Point(358, 88); this.baseDataGrid1.Name = "baseDataGrid1"; this.baseDataGrid1.Size = new System.Drawing.Size(240, 150
1) System.Windows.Forms.Button (1) System.Windows.Forms.Label (1) System.Drawing.SizeF (1) Visual Studio 2005 (1) System.Drawing.Point (1) If there is a limit, it's certainly not four. Rather something like 65536 screwed up because I designed this window in the same manner as all others using Visual Studio 2005. I did not override any behind the scene code. Thanks to everyone who replied GraphicsUnit.Point, ((byte)(0))); this.label1.ForeColor = System.Drawing.Color.Navy; this.label1.Location = new System.Drawing.Point(64, 9); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size
make a button do something. .NET Framework Hello, I have invested years and years into Visual Basic in Visual Studio and the MS Office products. Now, I???m taking a look at Visual c++ looking at it with Visual c++ Express 2008. It looks really promising. And there are some significant improvements since my old copy of Visual Studio was purhased. I have written many plain old c functions in the vc++ environment, and shown below??? this-> button1 = (gcnew System::Windows::Forms::Button()); this-> SuspendLayout(); / / / / button1 / / this-> button1-> Location = System::Drawing::Point(136, 23); this-> button1-> Name = L"button1"; this-> button1-> Size = System::Drawing::Size