Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Control array

Posted on 2014-11-21
3
Medium Priority
?
166 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 86

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 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

877 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