| | |
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 animation array barchart bitmap box broadcast c# check checkbox client code combobox control conversion csharp custom database datagrid datagridview dataset datastructure datetime degrees development directrobot draganddrop drawing encryption enum event excel file form format forms function gdi+ hash httpwebrequest image index input install java label lisp list listbox mandelbrot math mouseclick mp3 mysql native operator packaging path photoshop picturebox pixelinversion post print process programming radians regex remote remoting richtextbox safari server sleep snooze socket sql statistics stream string table tables tcp text textbox thread time timer update usercontrol usercontrols validation visualstudio webbrowser wfa windows winforms wpf xml





