Click here to Skip to main content
16,005,473 members
Home / Discussions / C#
   

C#

 
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 
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 
That code fails because you used 'button[i]' instead of buttonList[i].
button[i].Text = aanbodTableAdapter.GetFrisdranken().FindByid(i).ToString();


should be replaced with

buttonList[i].Text = aanbodTableAdapter.GetFrisdranken().FindByid(i).ToString();


An array of buttons is like, uhm, a series of buttons. So you can't access the array directly as if it was a button. You must identify the specific button in the array that you want to use, by an identifier. In this case we identify it by the integer 'i'.
So when defining

private System.Windows.Forms.Button []myButtonList = new Button[totaal];


you need to identify each of the buttons when you use them.

int totaal = 3;
private System.Windows.Forms.Button []myButtonList = new Button[totaal];

myButtonList[0] = new Button();
myButtonList[1] = new Button();
myButtonList[2] = new Button();

myButtonList[0].Text = "Button1"
myButtonList[1].Text = "Button2"
myButtonList[2].Text = "Button3"


or even easier with for loop:

public class foo : System.Windows.Forms.Form
{
   private System.Windows.Forms.Button []myButtonList = new Button[totaal];
   
   //Visual Studio autogenerated constructor and main method here

   //Call this from the constructor
   private void InitializeButtonArray()
   {
      for(int i = 0; i < totaal; i++)
      {
         myButtonList[i] = new Button();

         //maybe place them like this. Havent tried this... :S
         myButtonList[i].Location = new System.Drawing.Point(10 + i*10, 10);
         myButtonList[i].Dock = System.Windows.Forms.DockStyle.Left;
         myButtonList[i].Name = "Button" + i;  //i.e 'Button1', 'Button2' etc
         myButtonList[i].TabIndex = i;
         myButtonList[i].Text = "Text from your table";
         myButtonList[i].Click += new System.EventHandler(this.myButtonList_Click);
      }
   }

   private void myButtonList_Click(object sender, System.EventArgs e)
   {
        //some button click event handler code here
        //check on i.e button or buttonname.
   }
}


-Larantz-
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 
AnswerRe: vedio and powerpoint Pin
Judah Gabriel Himango2-May-06 5:55
sponsorJudah Gabriel Himango2-May-06 5:55 
QuestionRefactoring question (performance) Pin
gantww2-May-06 5:25
gantww2-May-06 5:25 

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.