Click here to Skip to main content
15,894,343 members
Home / Discussions / C#
   

C#

 
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 
QuestionBacking up my source Pin
Tom Wright2-May-06 7:16
Tom Wright2-May-06 7:16 
QuestionReports using Business Object in C# Pin
Neel072-May-06 6:54
Neel072-May-06 6:54 
AnswerRe: Reports using Business Object in C# Pin
shabonaa2-May-06 8:46
shabonaa2-May-06 8:46 
QuestionForm flicks when resize on Timer_Tick Pin
freshonlineMax2-May-06 6:49
freshonlineMax2-May-06 6:49 
AnswerRe: Form flicks when resize on Timer_Tick Pin
CWIZO2-May-06 8:42
CWIZO2-May-06 8:42 
QuestionObject Reference Error while accessing a treenode from a context menu event Pin
Jonathen Scalet2-May-06 5:57
Jonathen Scalet2-May-06 5:57 
AnswerRe: Object Reference Error while accessing a treenode from a context menu event Pin
Judah Gabriel Himango2-May-06 6:03
sponsorJudah Gabriel Himango2-May-06 6:03 
GeneralRe: Object Reference Error while accessing a treenode from a context menu event Pin
J0nScalet2-May-06 6:14
J0nScalet2-May-06 6:14 
GeneralRe: Object Reference Error while accessing a treenode from a context menu event Pin
Judah Gabriel Himango2-May-06 6:33
sponsorJudah Gabriel Himango2-May-06 6:33 
Questionvedio and powerpoint Pin
walaa ibraheem2-May-06 5:26
walaa ibraheem2-May-06 5:26 

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.