Solved

Control array

Posted on 2014-11-21
3
157 Views
Last Modified: 2014-11-21
Hi Experts,

I have a group of command buttons (around 50). When I read "1" from database I want to make 1 button visible. When I read "2" I want to make 2 buttons visible. and so on...I put all the buttons in groupbox control.


Thank you.
0
Comment
Question by:RadhaKrishnaKiJaya
3 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40458261
And your question is...
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 40458355
You want to make random buttons visible?...or more likely, certain ones based on some kind of naming convention you might have implemented for them?  Do you have these buttons listed in any kind of array / list already?

Give us more details...
0
 
LVL 9

Accepted Solution

by:
Valliappan AN earned 500 total points
ID: 40458445
You may do this either using Control List, or dynamically creating your controls as an example as given here in the below link, and change to create buttons instead of other controls, and use it for your dynamic creation of buttons. You may call the AddControl function as many times you wish, as also the RemoveControl functionality can be implemented:

Button DynButton;

if (ControlType.EndsWith("Button"))
   {
      DynButton = (System.Windows.Forms.Button)ControlObject;
      DynButton.Width = 200;
      DynButton.Text = "Dynamically Added Textbox.";
      DynButton.Click += new System.EventHandler(DynCtrl_Event);
   }

Open in new window


Refer: How to dynamically add a control without hardcoding the control type in Visual C# .NET or Visual C# 2005

HTH
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question