473,397 Members | 1,961 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,397 software developers and data experts.

Adding designer support to a custom tree control

Hey all... I posted this in the vs.net ide group too, but people are not answering, so I figured that it might be more appropriate here. I'm not sure if I'm adding a designer to my code properly. I'm only adding it to the tree node, where each custom tree node is then added to a normal tree control

I'm trying to get an add-in to interact with the property window in VS.Net. Basically, I created a tool window containing a custom tree control. When the user clicks on a tree node, I want certain properties to show up in the property window. My understanding is that I need to create a designer for the component, and override the prefilterproperties method. The problem right now is that when I use clicks a node, I get no update to the property window. Do I need to hook an event to notify the property window that the tree node was clicked? Documentation on this seems sort of sparse, so any help would greatly be appreciated.

Also, I've seen this article: http://www.msdn.microsoft.com/librar...dsgnrdotnet.as

Thank

Ji

Here are some snippets of what I already have

[Designer(typeof(MyTreeNodeDesigner))]
public class MyTreeNode : TreeNod

private XmlNode _xmlNode
private string _type = String.Empty

/// <summary
/// Represents the xml fragment for this My objec
/// </summary
public XmlNode XmlNod

get { return this._xmlNode;
set { this._xmlNode = value;
/// <summary
/// Represents the <see cref="IMyObject"/> type nam
/// </summary
public string Typ

get { return this._type;
set { this._type = value;
public MyTreeNode(string nodeName

this.Text = nodeName
public MyTreeNode(string nodeName, string name

this.Text = nodeName + " - '" + name + "'"

public class MyTreeNodeDesigner : System.Windows.Forms.Design.ControlDesigne

bool locked

private bool Locked

get

return locked

set

locked = value;

public MyTreeNodeDesigner(

protected override void PreFilterProperties(IDictionary properties

base.PreFilterProperties(properties)

properties["Locked"] = TypeDescriptor.CreateProperty
typeof(MyTreeNode),
"Locked",
typeof(bool), new Attribute[0])

Nov 15 '05 #1
9 5457

Hi Jim,

Thank you for posting in the community!

Based on my understanding, you want to write a customized TreeView control,
and you want to add some design-time support for it. That is, you want the
TreeNodes in the TreeView to be selected and modify properties from
Property Browser.

================================================== =====
I think this is a much complex work, and need a lots work to do.

In .Net Windows Form designer, TreeNode is container in the TreeView
control, and it design-time behavior is first be managed by the TreeView
control. So to get what you want, you should first write the designer for
the TreeView control.

The TreeView control actually use an INTERNAL
"TreeViewControlDesigner"(This name is bogus) for its design-time
behaviro(Not the default ControlDesigner). Because this designer is
internal, you must write a customized designer for your TreeView.

The code below will allow you to expand and collapse your TreeView
control.(This is not allowed for ControlDesigner class's default behaviro)

[Designer(typeof(MyTreeViewDesigner))]
public class MyTreeView : System.Windows.Forms.TreeView
{
}

public class MyTreeViewDesigner: System.Windows.Forms.Design.ControlDesigner
{
protected override bool GetHitTest(Point point)
{
return true;
}
}

And also, you must provide your customized designer for the TreeNode class.
Unfortunately, TreeNode is not a *control*(Does not inherited from
System.Windows.Forms.Control), and it does not implement IComponent
interface. So you can not apply ControlDesigner(More detailed,
ComponentDesigner) on it.

So you must implement the IComponent interface for the your TreeNode, then
user root designer's to add the TreeNode to the VS.net designer.

Till now, you will see how many thing you need to do to get this done(What
I stated may be not the whole work you should do, extra work may need). I
strongly recommanded that you use other way to workaround.

I think you may use CollectionEditor for TreeView's Nodes property. And
modify the TreeNode's property in the Editor.

================================================== =========
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Have a nice day!!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #2

Hi Jim,

Thanks very much for your feedback.

I have reviewed your post, I will spend sometime in review that articles.

I will reply to you ASAP after research.

Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #3

Hi Jim,

After quick reviewing the article for the first time, I found some of its
features are the run-time property editing.

Do you want to edit your treenode at run-time or design-time?

If you want to get this done at run-time, you only need to use PropertyGrid
control on your Form.

For an article about how to use Property Grid in your WinForm application,
please refer to:
http://msdn.microsoft.com/library/de...us/dndotnet/ht
ml/usingpropgrid.asp

If you need the runtime feature, please feel free to feedback to me

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #4
Hey Jeffrey

I'll need to make use of the run-time property editing. I'll have a collection of unique attributes that will need to be available to the property grid in VS.Net. I will not know what those attributes names or values are until run-time, but I would like each of them to show up in the grid. Also, I will not be able to setup properties for each of the attributes, so I am looking for a way to programatically add designer support at run-time. For example, rather than being able to add specific classes to my project, like this

public class MyPropertie

[CategoryAttribute("Attributes")
DefaultValueAttribute("SomeValue")]
public string PropertyNam
{ get { return this.value;
set { this.value = value;

Ideally, I want to be able to dynamically add PropertyName with a default value of "SomeValue" and assigned to category "Attributes" to the propertygrid at run-time

To use an example, I want to take an XmlNode and display each of the attributes for that node in the property grid. Each xml attribute would display in the grid as the attribute name and have it's associated value. Since I don't know what node attributes will be present, I'll need to add the properties to the grid dynamically

Also, since the property grid control is outside of my application, I don't believe that I'll have control over setting the SelectedObject property for it

I hope this sort of clears up what I'm looking to accomplish

Thanks for all your help and patience with this

Jim
Nov 15 '05 #5

Hi Jim,

Thanks very much for your feedback.

For your feedback, I understand that you want the run-time property editing
function.

But I am not fully understand your description, I think I will clarify some
concept for you and ask some further information from you.

================================================== ====
First, PropertyGrid is a .Net WinForm control, which can be used on the
Windows Form application at run-time(As a property designe support). While
in VS.net IDE, PropertyBrowser is a design-time browser for the designer
controls. For your reqest, I think you can make use of PropertyGrid control
in your application, but why you say: " property grid control is outside of
my application, I don't believe that I'll have control over setting the
SelectedObject property for it."?

Second, in your first paragraph's description "I will not know what those
attributes names or values are until run-time", what does *attribute* mean?
Does it mean Property?
Or it is really the attributes of the property?(Such as the
ReadOnlyAttribute, CategoryAttribute).

For "I will not be able to setup properties for each of the attributes",
what does "property for the attributes" mean? Does it mean the value of
these attributes?(Such as true or false for ReadOnlyAttribute, the category
string value for the CategoryAttribute)

Please clarify these things for me, so that I can help you better.

================================================== ===
I will wait for your further feedback. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #6

Hi Jim,

Thanks very much for your feedback.

I have reviewed your post, I see your concern.

I have got some clue about this issue, but I will clean up my mind and
provide your more integrated information for it.
I will reply to you ASAP.

Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #7

Hi Jim,

I think you want to read the xml nodes in the xml file, then display their
attributes in the propertygrid dynamicly.

========================================
Actually, to get this done you can create a class which implement the
ICustomTypeDescriptor interface.

You should create your own propertydescriptor class(Inherit the
PropertyGrid class), then in ICustomTypeDescriptor.GetProperties() method,
you can create your own PropertyDescriptorCollection with your
propertydescriptor.

Do like this:

public PropertyDescriptorCollection
GetProperties() {
PropertyDescriptor[] pd = new
PropertyDescriptor[node.Attributes.Count];
for (int i = 0; i < node.Attributes.Count; i++)
pd[i] = new
MyPropertyDescriptor(node.Attributes[i].Name);
return new PropertyDescriptorCollection(pd);
}
}

Note: the node is the xmlnode of your xml file.

You also can add various attribute on your property at runtime through this
interface.

There is an article "Bending the .NET PropertyGrid to Your Will" teaches
you how to Implement ICustomTypeDescriptor interface and do customize
property display, please refer to:
http://www.codeproject.com/cs/miscct...g_property.asp

Also, these 2 articles may help you:
http://www.codeproject.com/cs/miscct...ta.asp?target=
ICustomTypeDescriptor
http://www.codeproject.com/cs/miscct...asp?target=ICu
stomTypeDescriptor

=============================================
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Have a nice day!!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #8
Ok, I'll give that a shot and let you know if I run into any issues.

Thanks Jeffrey!

Jim
Nov 15 '05 #9

Hi Jim,

Thanks very much for your feedback.

I will wait for your feedback, if there is still something unclear, please
feel free to post, I will help you.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Andy Bates | last post by:
I have hopefully a simple problem in C#. I designed a form with a listview on left, vert splitter against that, then the remainder of the form from top to bottom: a listview, horiz splitter and...
7
by: Martin Schulze | last post by:
Hello, i tried to compose myself a custom usercontrol which is derieved from System.Windows.Forms.UserControl. It contains 2 comboboxes and one textbox (which are also custom controls, but...
3
by: Casper | last post by:
Hi .Net experts, I am trying to build a user control of textbox and would like to add a public method to the object like public void CheckOptions(string str) { // codes here }
19
by: Dales | last post by:
I have a custom control that builds what we refer to as "Formlets" around some content in a page. These are basically content "wrapper" sections that are tables that have a colored header and...
1
by: sianan | last post by:
I tried to use the following example, to add a checkbox column to a DataGrid in an ASP.NET application: http://www.codeproject.com/aspnet/datagridcheckbox.asp For some reason, I simply CAN'T get...
1
by: npaulus | last post by:
Hi, I am trying to dynamically add user controls on to my web form but for some reason my form isnt displaying the user control. form1.cs: using System; using System.Drawing; using...
11
by: Pete Kane | last post by:
Hi All, does anyone know how to add TabPages of ones own classes at design time ? ideally when adding a new TabControl it would contain tab pages of my own classes, I know you can achieve this with...
4
by: Goran Djuranovic | last post by:
Hi all, I am experiencing a strange thing happening with a "designer.vb" page. Controls I manually declare in this page are automatically deleted after I drop another control on a ".aspx" page. -...
6
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
Yesterday Visual Studio gave me a strange error both at compiletime and at designtime that had no obvious connection to anything I had changed recently. After some effort tracking down the problem...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.