PropertyGrid Control abilities.

M

Mr. X.

Hello.
I am using PropertyGrid, to expose the control properties (as IDE does),
1. For some properties, the property-editor is not working as usual :
a. Columns property in DataGridView , when clicking on the button to
show the columns : there is no window - why? and can I enable this?
b. How can I connect control to other controls, by using the
PropertyGrid? I.e. On a panel there is a property "ContextMenuStrip".
2.How can I make one of the property invisible. Suppose I want that
borderStyle on pnlMain should not be visible on PropertyGrid?

Thanks :)
 
T

Tom Shelton

After serious thinking Mr. X. wrote :
Hello.
I am using PropertyGrid, to expose the control properties (as IDE does),
1. For some properties, the property-editor is not working as usual :
a. Columns property in DataGridView , when clicking on the button to show
the columns : there is no window - why? and can I enable this?
b. How can I connect control to other controls, by using the
PropertyGrid? I.e. On a panel there is a property "ContextMenuStrip".
2.How can I make one of the property invisible. Suppose I want that
borderStyle on pnlMain should not be visible on PropertyGrid?

Thanks :)

You might look here

http://tom-shelton.net/index.php/2009/10/07/creating-a-simple-hotkey-component-using-registerhotkey/

I'm not sure if it will answer all your questions - but, it is a simple
component that implements custom property editors, etc.
 
J

Jeff Johnson

I am using PropertyGrid, to expose the control properties (as IDE does),
1. For some properties, the property-editor is not working as usual :
a. Columns property in DataGridView , when clicking on the button to
show the columns : there is no window - why? and can I enable this?
b. How can I connect control to other controls, by using the
PropertyGrid? I.e. On a panel there is a property "ContextMenuStrip".
2.How can I make one of the property invisible. Suppose I want that
borderStyle on pnlMain should not be visible on PropertyGrid?

There's a really good Code Project article on controlling the PropertyGrid:
http://www.codeproject.com/KB/miscctrl/bending_property.aspx
 
M

Mr. X.

Where is fireAnt (The code is not compiling due code :
using FireAnt.Windows.Forms.Util ?

Thanks :)
 
T

Tom Shelton

After serious thinking Mr. X. wrote :
Where is fireAnt (The code is not compiling due code :
using FireAnt.Windows.Forms.Util ?

Thanks :)

I just downloaded the hotkeylib.zip, uzipped it to my desktop, opened
the sln in vs and compiled it just fine.

What version of vs are you using? There are no external dependencies
(other then framework references)....
 
M

Mr. X.

I still have a problem.

I shall be more specific :
===============
For the following code :
private void getTypeTest(Control c, string propertyName)
{
PropertyInfo pi;
pi = c.GetType().GetProperty(propertyName);
if (pi != null)
{
foreach (System.Attribute att in
pi.PropertyType.GetCustomAttributes(true))
{
if (att is System.ComponentModel.EditorAttribute)
{
System.ComponentModel.EditorAttribute attEdit;
attEdit =
(System.ComponentModel.EditorAttribute)att;
MessageBox.Show(attEdit.EditorTypeName);
}
}
}
}


If I pass parameters :
c : DataGridView1 (object that is on my form)
propertyName : Columns.

....
There is no editor for columns, but on design-time there is an editor.
**************** I need to use that editor for Columns *****************

for parameters, I.e :
c : Button1 (object button that is on my form)
propertyName : Font

There is System.Drawing.Design,fontEditor.

Why for DataGridView.Columns, I cannot see it's propertyEditor (what is it
?)
Even when connecting to PropertyGrid, I cannot use the editor for columns,
as I see on designer.

Thanks :)
 
M

Mr. X.

Succeed.
Good example, thanks.

I don't want to custom property-editor, but use something that already
exists.

Thanks, anyway :)
 
M

Mr. X.

Well,
I change a bit the code, and found the property editor,
but I don't know what's next.

Here is the code :
=============
private void getTypeTest(Control c, string propertyName)
{
PropertyDescriptor pd;
EditorAttribute e;
pd = TypeDescriptor.GetProperties(c)[propertyName];
e = (EditorAttribute)pd.Attributes[typeof(EditorAttribute)];
if (e != null)
{
MessageBox.Show(e.EditorTypeName);
MessageBox.Show(e.EditorBaseTypeName);
}
}

If I pass :
c : DataGridView1 (object that is on my form)
propertyName : Columns.

I can see that editortype & editorbasetype respectively are :
System.Windows.Forms.Design.DataGridViewColumnCollectionEditor
System.Drawing.Design.UITypeEditor.

1. I cannot find the :
System.Windows.Forms.Design.DataGridViewColumnCollectionEditor
2. What's next that I should do.

Thanks :)
 
M

Mr. X.

To understand something:
=================
Why on ModifierKeysEditor.GetEditStyle only return
UITypeEditorEditStyle.DropDown; works (shows the ModifierKeyEditorUI -
otherwise,
I cannot enter EditValue Method (When ModifierKeysEditor.GetEditStyle
returns ModifierKeysEditor.GetEditStyle.Modal or
ModifierKeysEditor.GetEditStyle.None,
I cannot see the ModifierKeyEditor, neither EditValue method isn't
reachable.
For ModifierKeysEditor.GetEditStyle=UITypeEditorEditStyle.DropDown I can
reach EditValue method).

Thanks :)
 

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