A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

adding controls programmatically



 
 
Thread Tools Display Modes
  #1  
Old December 20th, 2005, 01:44 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default 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  
Old December 20th, 2005, 02:28 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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


All times are GMT +1. The time now is 06:50 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.