PropertiesGrid and opening forms

S

Shawn Hogan

Hi,

I have a 3rd party control(infragistics) that seems to alter the VS.NET IDE
properties grid so that there are three areas instead of two areas in the
VS.NET IDE properties grid. There is a new middle area that looks a lot like
the description area except it has hyperlinks that open forms that allow the
currently displayed control to be edited.

Does anyone know how to do this with the properties grid in VS.NET? Is the
properties grid used in the IDE the same as the one that you can use in your
projects?

Thanks,
Shawn
 
W

William Ryan [eMVP]

You can do this by setting the Description And Category attributes of your
component. Also, if you have a property of your control that has an enum
for instance, it'll show up as a combo box in the property grid. If you
have an indexer, you'll have the little button that will pop up the form to
let you add items. The behavoir of things inside the grid is largely
dependent on how you set up your properties, but to get the Description and
Category to change, it's as easy as adding an attribute
<Description("Whateever you want it to say"), Category("Behavior"),
DefaultValue(Whatever You want Here")

HTH,

Bill
 
S

Shawn Hogan

The area i'm talking about isn't the "description" area... it's another one
that's between the grid and tre description area. Inside of this area is a
list of links which open up forms.

The reason why i'm so interested in this area is because i want to open a
form to edit properties in the selected object from the properties grid. The
catch is that the form cannot be modal. I need to interact with the
application when i have the form open.

Shawn
 
W

William Ryan [eMVP]

I just opened Infragistics and see what you are talking about. I'm not sure
off of the top of my head, but I have an idea..I'll get back to you
shortly..

Bill
 
P

Philip Rieck

Any control can show these, but it does require a small amount of work:

Your control needs to have a designer defined (that is,
[Designer(typeof(SomeDesigner))]
public class SomeControl : System.Windows.Forms.UserControl // Or
Control, or an asp.net control whatever. it must inherit from component

Your designer will most likely inherit from ControlDesigner, or some such.
To add these "hyperlinks", you add Verbs. You can do this by overriding the
"Verbs" property of your designer ...

public class SomeDesigner : ControlDesigner{
....
DesignerVerbCollection _verbs;
public override DesignerVerbCollection Verbs{
get{
if(_verbs == null)
{
_verbs = new DesignerVerbCollection();
_verbs.Add (
new DesignerVerb("Cool Action", new
EventHandler(CoolAction_Handler)));
}
return _verbs;
}
}
....

Then you just code the function you passed in as a delegate above:

private void CoolAction_Handler(object sender, EventArgs e){
//Do something neat
}
 
P

Philip Rieck

Sorry that was in c#.. I lost track of the NG I was in! (also note that I
have no VS.NET here... this code is almost-code, as it's never been syntax
checked. Hopfully the concepts don't suffer.)

The concept is the same -> add the Designer attribute to your class:
<Designer ... >
Public Class SomeControl
Inherits System.Windows.Forms.Control
....

Then implement the designer and override the Verbs Property.
Private _verbs As DesignerVerbCollection
Public Property Verbs As DesignerVerbCollection
Get
If _verbs Is Nothing Then
_verbs.Add( _
new DesignerVerb( "Cool Action", AddressOf( CoolAction_Handler)))
End If
Return _verbs
End Get
End Property
....
Then implement the handler:

Private Sub CoolAction_Handler( sender As Object, e As EventArgs)
'something neat goes here.
End Sub


Philip Rieck said:
Any control can show these, but it does require a small amount of work:

Your control needs to have a designer defined (that is,
[Designer(typeof(SomeDesigner))]
public class SomeControl : System.Windows.Forms.UserControl // Or
Control, or an asp.net control whatever. it must inherit from component

Your designer will most likely inherit from ControlDesigner, or some such.
To add these "hyperlinks", you add Verbs. You can do this by overriding the
"Verbs" property of your designer ...

public class SomeDesigner : ControlDesigner{
...
DesignerVerbCollection _verbs;
public override DesignerVerbCollection Verbs{
get{
if(_verbs == null)
{
_verbs = new DesignerVerbCollection();
_verbs.Add (
new DesignerVerb("Cool Action", new
EventHandler(CoolAction_Handler)));
}
return _verbs;
}
}
...

Then you just code the function you passed in as a delegate above:

private void CoolAction_Handler(object sender, EventArgs e){
//Do something neat
}





William Ryan said:
I just opened Infragistics and see what you are talking about. I'm not sure
off of the top of my head, but I have an idea..I'll get back to you
shortly..

Bill
another
one
is
open
a grid.
The of
your a
lot
VS.NET?
Is use
in
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top