Re-read what I said, THEN reply. Otherwise, don't bother. You're
missing the point.

∞ Andy Badera
∞ +1 518-641-1280
∞ This email is: [ ] bloggable [x] ask first [ ] private
∞ Google me: http://www.google.com/search?q=andrew%20badera



On Tue, Oct 13, 2009 at 4:57 AM, Awadhendra Tiwari
<[email protected]> wrote:
>
> hi...........
> what ever i understand ur question is that u want to add the button
> with the help of array and want  to make the single event handler..
> i give u the full program
> i think miner error u can solve
> public static void createButton()
> {
>   Button [] b1=new Button[10];//here we initilize the button array
>   //now we allocate memory to each button
>   for(int i=0;i<10;i++)
>   {
>       b1[i]=new Button(name[i]); //where name is the array of string type
>       b1[i].setBounds........//implement bounds method
>       this.Controls.Add(b1[i]);//Adding all the buttons to the form
>       this[i].Click+=new EventHandler(clickbutton());
>    }
> }
>
> protected void clickbutton(Object sender,ActionEventArgs evt)
> {
>     Button b=(Button)sender;
>     if(b=b1[i])
>        //implement the code
>        //one thing important u have to made the button array as a Member array
> }
>
> Now if u add any botton in any sequence simply add the button and
> register it with
> the same fumction
> as here
>
> Button b12=new Button("aAA");
> b12.setBounds(......);
> this.controls.Add(b12);
> b12.Click+=new EventHandler(clicknutton());
>
> On 10/13/09, Andrew Badera <[email protected]> wrote:
>>
>> Nooooooo ...
>>
>> That is just about the least-flexible way to possibly do this. What if
>> you add buttons? What if you add buttons early on in the sequence?
>> Which mechanism fails more gracefully in the event of error when
>> adding buttons?
>>
>> ∞ Andy Badera
>> ∞ +1 518-641-1280
>> ∞ This email is: [ ] bloggable [x] ask first [ ] private
>> ∞ Google me: http://www.google.com/search?q=andrew%20badera
>>
>>
>>
>> On Tue, Oct 13, 2009 at 12:10 AM, Awadhendra Tiwari
>> <[email protected]> wrote:
>>>
>>> write down the following code---
>>>
>>> protected void button1_click(Object sender,EventArgs e)
>>> {
>>>     Button b=(Button)sender;
>>>     if(b==b1[0])//here b1[0],b1[1] are the array on which u create
>>> the button array
>>>     {
>>>     //Perform the action for the first button
>>>     }
>>>     if(b==b1[1])
>>>     {
>>>        //perform the action for the second buton
>>>      }
>>>      ////and co on
>>> }
>>>
>>
>

Reply via email to