On Tue, 28 Aug 2007 08:35:49 +0100, "Marc Gravell"
<ma**********@gmail.comwrote:
>So I assume you are using PropertyGrid on your user-facing UI?
The quickest option here is probably to use BrowsableAttributes on the
PropertyGrid (below)
Marc
using System;
using System.ComponentModel;
using System.Windows.Forms;
static class Program {
static void Main() {
Application.EnableVisualStyles();
using(Form f = new Form())
using (PropertyGrid grid = new PropertyGrid()) {
f.Text = "BrowsableAttributes demo";
grid.Dock = DockStyle.Fill;
grid.SelectedObject = new SomeData();
grid.BrowsableAttributes = new AttributeCollection(new
BrowsableAttribute(true), new UserFacingAttribute());
f.Controls.Add(grid);
Application.Run(f);
}
}
}
well no i am not using the property grid, this program is designed
like this (not my design, som q&d vb6 programmer did it):
user control
communication class : user control
baseclass : communication class
my control : base class (from base class new controls are derived)
then in "my control" there are a number of properties like the normal
location, autosize etc. and some custom ones
e.g.
[Description("String to display instead of the value if the value is
above high range or below low range."), Category("Appearance")]
public string OutOfRangeString
{
get { return this.outOfRangeString; }
set
{
this.outOfRangeString = value;
...
}
}
[DisplayName("Numeric Items"), Browsable(false)]
public NumericValueColorWrapperCollection NumericItems
{
get { return this.numNumValColorWrapCol; }
}
so far that works, however having it like this makes for a lot for
similar coding in each control and it feels as if one can do it better
than this? saving/loading the properties calls a method in the base
class.
i still want to force users to implement the communication methods but
in the base class there are a lot of other gonk which makes each "my
control" quite version sensitive, my idea was to separate the library
stuff from the communication making the comm an interface and the lib
stuff a member instance in the "my control's", then using reflection
to get hold of the methods that way making it more resilient against
versioning.
i appreciate a lot your input! I hope I have expressed myself clearly
even though i went slightly off-topic :)
br/ajk