Hi
I've created some buttons at runtime and all these are having unique names
and also created event handler for the buttons created at run time like this
{
btn.Size =new System.Drawing.Size(70,50);
btn.Name ="Btn"+i;
btn.Text ="Newly Created Button" + i ;
btn.Click+=new EventHandler(btn_click);
this.Controls.Add(btn);
}
//////// handling event for newly creaetd buttons
private void btn_click(object sender, EventArgs e)
{
label1.Text= sender.Name;
}
when i tried to run the application then i got error "object does not
contain a definition for 'Name' "
and the same code executed in vb.net and it is display the button which i've
clicked.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim i As Integer
For i = 1 To 2
Dim btn As New Button
btn.Name = "B" & i
btn.Text = "First Button"
Me.Controls.Add(btn)
AddHandler btn.Click, AddressOf btn_click
Next
End Sub
Private Sub btn_click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Label1.Text = sender.Name
End Sub
Can any one tell me how to do this in c#.net?
Thanx in advance
Jyothi