| | |
Property Grid Problem
Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Aug 2009
Posts: 3
Reputation:
Solved Threads: 0
I've been working on a project for a few days now and have hit a part of the project that I don't know how to fix. I have a propertygrid control on the form and buttons that create controls when pressed.
Here's how I am creating the controls:
Then when the user clicks on the control it brings up a list of properties in the property grid using the method SelectEditableControl. All created controls use this method.
The problem is when you have created multiple controls . It won't change objects it just stays on the current object. I was thinking about setting the propertygrid's selectedobject to null but this didn't work. Thanks in advance for any help.
Here's how I am creating the controls:
C# Syntax (Toggle Plain Text)
private void button1_Click(object sender, EventArgs e) { Button homebtn = new Button(); homebtn.Text = "New Button"; homebtn.Location = new Point(20, 20); homebtn.Size = new System.Drawing.Size(75, 23); homebtn.Name = "Control" + Convert.ToString(controlnum); controlnum= controlnum+1; this.panel1.Controls.Add(homebtn); homebtn.Click += new System.EventHandler(this.SelectEditableControl); homebtn.MouseMove += new System.Windows.Forms.MouseEventHandler(this.MoveControl); homebtn.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ControlMouseDown); }
Then when the user clicks on the control it brings up a list of properties in the property grid using the method SelectEditableControl. All created controls use this method.
C# Syntax (Toggle Plain Text)
public void SelectEditableControl(object sender, EventArgs e) { propertyGrid1.SelectedObject = sender; propertyGrid1.Refresh(); }
The problem is when you have created multiple controls . It won't change objects it just stays on the current object. I was thinking about setting the propertygrid's selectedobject to null but this didn't work. Thanks in advance for any help.
Last edited by Rezant; Aug 13th, 2009 at 11:25 am.
•
•
Join Date: Nov 2006
Posts: 436
Reputation:
Solved Threads: 72
I changed your code so that you can actually click on the other buttons.
// Jerry
C# Syntax (Toggle Plain Text)
public partial class Form1 : Form { private int controlnum = 0; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Button homebtn = new Button(); this.panel1.Controls.Add(homebtn); homebtn.Text = "New Button" + controlnum.ToString(); homebtn.Location = new Point( 20, controlnum * 23); homebtn.Size = new System.Drawing.Size(175, 23); homebtn.Name = "Control" + controlnum.ToString(); controlnum = controlnum + 1; homebtn.Click += new System.EventHandler(this.SelectEditableControl); } public void SelectEditableControl(object sender, EventArgs e) { propertyGrid1.SelectedObject = sender; propertyGrid1.Refresh(); } }
// Jerry
•
•
Join Date: Aug 2009
Posts: 3
Reputation:
Solved Threads: 0
that wasn't a problem in my project seeing as all the controls are movable, but that could be a problem for others. =) The problem actually was with the custom control I was using. The dll I downloaded from Codeproject was apparently broken, but a fix was available
Last edited by Rezant; Aug 14th, 2009 at 12:47 am.
![]() |
Similar Threads
- Grid problem (C)
- TreeView & Property Grid (VB.NET)
- javascript grid getting problem in Internet Explorer (JavaScript / DHTML / AJAX)
- Problem with proprety grid (C#)
- In navigation display:block; property is giving problem in IE6 (HTML and CSS)
- How to set decimal digits to 2 for a double type data field in grid control (Visual Basic 4 / 5 / 6)
- Variable Problem (Visual Basic 4 / 5 / 6)
Other Threads in the C# Forum
- Previous Thread: Update website control from usercontrol?
- Next Thread: C# Applet?
| Thread Tools | Search this Thread |
.net access algorithm array asp.net barchart bitmap box broadcast c# check checkbox client combobox control conversion csharp custom database databaseconnection datagrid datagridview dataset datetime dbconnection degrees design development draganddrop drawing encryption enum event eventhandlers excel file firefox form format forms function gdi+ grantorrevokepermissionthroughc#.net httpwebrequest image index input install java label libraries list listbox loop mandelbrot marshalbyrefobject math mouseclick movingimage mysql mysql.data.client operator path photoshop php picturebox pixelinversion post programming radians regex remoting resourcefile richtextbox server sleep socket sql statistics stream string study system.servicemodel table tcpclientchannel text textbox thread time timer update usercontrol validation visualstudio webbrowser windows winforms wpf wpfc# xml





