If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
adding controls programmatically
I am trying to add controls (e.g. radio buttons, group boxes) to a
windows form in a method which I call from the constructor. However, when I do things like; RadioButton rb= new RadioButton(); .... rb.Location.X= 67; this.Controls.Add(rb); // this is the Windows Form instance I am told that; "Cannot modify the return value of 'System.Window.Forms.Control.Locatoin' because it is not a variable" I have tried to use CreateControl() but it doesn't seem to have any effect. If anyone knows how to do this please help asap John |
#2
|
|||
|
|||
adding controls programmatically
Adding controls programmatically is never a good idea. First, you should be
using the CreateControl method and the form has to be in design view. One of the problems you will probably run into is there is a lifetime limit of 754 controls on a form; so, each time you run the form and create a control, that deducts from the limit. Eventually, the form will fail. I don't know exactly what you are trying to do, but here are some alternatives to consider. Create enough radio buttons on the form to handle any eventuality and make them all Visible = No. Then make them visible as you need them rather than create them. You can even change the caption of their labels if necessary. Another way would be to use a combo box or list box to allow the user to make a selection. "johnmmcparland" wrote: I am trying to add controls (e.g. radio buttons, group boxes) to a windows form in a method which I call from the constructor. However, when I do things like; RadioButton rb= new RadioButton(); .... rb.Location.X= 67; this.Controls.Add(rb); // this is the Windows Form instance I am told that; "Cannot modify the return value of 'System.Window.Forms.Control.Locatoin' because it is not a variable" I have tried to use CreateControl() but it doesn't seem to have any effect. If anyone knows how to do this please help asap John |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
tab forms and adding controls to my tab form | Miguel Vivar | New Users | 1 | December 20th, 2005 03:29 PM |
Maximum # of Controls on a Form... | Bob Barnes | General Discussion | 4 | November 22nd, 2005 03:06 PM |
Renmaing all controls on a form | SmilingPolitely | General Discussion | 1 | June 11th, 2005 01:10 AM |
Would like advice on resetting form controls after Undo | Jon A | Using Forms | 3 | February 13th, 2005 11:35 PM |
check box that disables itself and other controls after use | Dave | General Discussion | 4 | February 10th, 2005 05:23 PM |