Click here to Skip to main content
15,916,030 members
Home / Discussions / C#
   

C#

 
AnswerRe: how to set focus a control in c# Pin
Tom Larsen2-May-06 11:32
Tom Larsen2-May-06 11:32 
AnswerRe: how to set focus a control in c# Pin
Ravi Bhavnani2-May-06 12:44
professionalRavi Bhavnani2-May-06 12:44 
AnswerRe: how to set focus a control in c# Pin
HimaBindu Vejella2-May-06 19:16
HimaBindu Vejella2-May-06 19:16 
QuestionC# variables with variabel part Pin
JelleM2-May-06 8:30
JelleM2-May-06 8:30 
AnswerRe: C# variables with variabel part Pin
CWIZO2-May-06 8:40
CWIZO2-May-06 8:40 
GeneralRe: C# variables with variabel part Pin
JelleM2-May-06 8:49
JelleM2-May-06 8:49 
GeneralRe: C# variables with variabel part Pin
Larantz2-May-06 9:09
Larantz2-May-06 9:09 
GeneralRe: C# variables with variabel part Pin
JelleM2-May-06 9:32
JelleM2-May-06 9:32 
GeneralRe: C# variables with variabel part Pin
Dan Neely2-May-06 9:44
Dan Neely2-May-06 9:44 
GeneralRe: C# variables with variabel part Pin
JelleM2-May-06 10:00
JelleM2-May-06 10:00 
GeneralRe: C# variables with variabel part Pin
CWIZO2-May-06 10:11
CWIZO2-May-06 10:11 
GeneralRe: C# variables with variabel part Pin
JelleM2-May-06 10:19
JelleM2-May-06 10:19 
GeneralRe: C# variables with variabel part Pin
Dan Neely2-May-06 10:17
Dan Neely2-May-06 10:17 
GeneralRe: C# variables with variabel part Pin
Josh Smith2-May-06 10:18
Josh Smith2-May-06 10:18 
GeneralRe: C# variables with variabel part Pin
JelleM2-May-06 10:23
JelleM2-May-06 10:23 
GeneralRe: C# variables with variabel part Pin
Ravi Bhavnani2-May-06 12:47
professionalRavi Bhavnani2-May-06 12:47 
GeneralRe: C# variables with variabel part Pin
JelleM3-May-06 5:05
JelleM3-May-06 5:05 
GeneralRe: C# variables with variabel part Pin
Larantz3-May-06 10:42
Larantz3-May-06 10:42 
Like I said before:

You can create an array of buttons. An array is a list of objects.
To do this, you add brackets '[]' when creating a variable, i.e button variable or integer variable.

int [] myInts = new int[2].
for(int i = 0; i < myInts.Length; i++)
   myInts[i] = some integer value.


As for the code you need, you can do this:

int totaal = this.aanbodTableAdapter.CountFrisdranken().Value;
Button []buttonList = new Button[totaal];

for (int i = 0; i < buttonList.Length; i++)
{
   buttonList[i] = new Button();
   button[i].Text = aanbodTableAdapter.GetFrisdranken().FindByid(i).ToString();
}


You'd also have to set the location for your new buttons, so there's plenty of neccessary code missing here. But it should give you an idea of how to create a dynamic array consisting of buttons. Smile | :)

Have you concidered using a ComboBox instead? Might be hard to place 100 buttons on a form.

I.e add a combobox to your form in designview and call it myComboBox.

int totaal = this.aanbodTableAdapter.CountFrisdranken().Value;
ArrayList listItems = new ArrayList();

for (int i = 0; i < totaal; i++)
{
   listItems.Add(aanbodTableAdapter.GetFrisdranken().FindByid(i).ToString());
}

myComboBox.DataSource = listItems;


-Larantz-

-- modified at 16:47 Wednesday 3rd May, 2006
GeneralRe: C# variables with variabel part Pin
JelleM3-May-06 10:55
JelleM3-May-06 10:55 
GeneralRe: C# variables with variabel part Pin
Larantz4-May-06 7:55
Larantz4-May-06 7:55 
GeneralRe: C# variables with variabel part Pin
Larantz4-May-06 9:54
Larantz4-May-06 9:54 
QuestionHovering Mouse Pin
IceWater422-May-06 8:24
IceWater422-May-06 8:24 
AnswerRe: Hovering Mouse Pin
Pablo Hernandez Valdes2-May-06 8:40
Pablo Hernandez Valdes2-May-06 8:40 
GeneralRe: Hovering Mouse Pin
IceWater422-May-06 12:24
IceWater422-May-06 12:24 
Questionhow to SetParameterValue to crystal sub-report using c# Pin
shabonaa2-May-06 8:01
shabonaa2-May-06 8:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.