Solved

Control array

Posted on 2014-11-21
3
153 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 74

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now