473,729 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 prefilterproper ties 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 (MyTreeNodeDesi gner))]
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(stri ng nodeName

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

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

public class MyTreeNodeDesig ner : System.Windows. Forms.Design.Co ntrolDesigne

bool locked

private bool Locked

get

return locked

set

locked = value;

public MyTreeNodeDesig ner(

protected override void PreFilterProper ties(IDictionar y properties

base.PreFilterP roperties(prope rties)

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

Nov 15 '05 #1
9 5488

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
"TreeViewContro lDesigner"(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 (MyTreeViewDesi gner))]
public class MyTreeView : System.Windows. Forms.TreeView
{
}

public class MyTreeViewDesig ner: System.Windows. Forms.Design.Co ntrolDesigner
{
protected override bool GetHitTest(Poin t 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,
ComponentDesign er) 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 CollectionEdito r 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.a sp

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

[CategoryAttribu te("Attributes" )
DefaultValueAtt ribute("SomeVal ue")]
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
ReadOnlyAttribu te, CategoryAttribu te).

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?(Suc h as true or false for ReadOnlyAttribu te, the category
string value for the CategoryAttribu te)

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
ICustomTypeDesc riptor interface.

You should create your own propertydescrip tor class(Inherit the
PropertyGrid class), then in ICustomTypeDesc riptor.GetPrope rties() method,
you can create your own PropertyDescrip torCollection with your
propertydescrip tor.

Do like this:

public PropertyDescrip torCollection
GetProperties() {
PropertyDescrip tor[] pd = new
PropertyDescrip tor[node.Attributes .Count];
for (int i = 0; i < node.Attributes .Count; i++)
pd[i] = new
MyPropertyDescr iptor(node.Attr ibutes[i].Name);
return new PropertyDescrip torCollection(p d);
}
}

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 ICustomTypeDesc riptor 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=
ICustomTypeDesc riptor
http://www.codeproject.com/cs/miscct...asp?target=ICu
stomTypeDescrip tor

=============== =============== ===============
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
2357
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 tab control (very similar to outlook express). I then started coding and realised that I needed to add a ToolBar. When I added this, it didn't appear at the top as expected, but at the top of the tab control and I couldn't get it to appear where...
7
12503
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 directly derived from the .net classes ComboBox and TextBox) I did the custom control in the visual studio .net designer in which i
3
2068
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
2983
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 provide an open TD with a DIV in it for the content of this formlet. (The DIV is for DHTML to hide and show the content) I've created a web page showing step by step the two problems I'm encountering. This problem is much easier to see than it...
1
4235
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 the example to work. I created the following two classes, provided with the example: *-*-**-*-*-*-*-*-*-*-*-*-**-*-*-*-*-CheckBoxColumn Class:-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-**-*-*-*
1
4079
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 System.Collections; using System.ComponentModel; using System.Windows.Forms;
11
18138
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 ListView columns so it should be doable, thanks
4
2645
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. - Why is this happening? - Can I disable automatic declaration and have everything be declared manually? - Any other options to fix this? Thanks in advance. Goran Djuranovic
6
3342
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 I discovered first a workaround, then the real cause of the problem. I would like to understand why what I am doing is frowned upon by Visual Studio and how to do this properly. My application is in one solution; supporting libraries including...
0
9427
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9284
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9202
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8151
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4528
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4796
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2165
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.