hazejean Posted September 3, 2003 Posted September 3, 2003 I am creating button at execution time because location varies. I am not getting control code that is suppose to be generated.Any ideas? heres my code: button1 = New Button button1.Location = New Point(1, 18 * (i - 5)) Controls.Add(button1) button1.Text = "SUBMIT" Quote
Administrators PlausiblyDamp Posted September 3, 2003 Administrators Posted September 3, 2003 button1.visible = true Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
*Experts* Volte Posted September 3, 2003 *Experts* Posted September 3, 2003 Not sure what you mean by "control code that is supposed to be generated." The only control code which is generated is created when you draw a control on the form with the designer. Your code is not altered when you dynamically add a control. However, Button1.Show() should cause the button to appear. [edit]D'oh, I got sidetracked by another post and didn't push Submit[/edit] Quote
*Experts* Volte Posted September 3, 2003 *Experts* Posted September 3, 2003 I got this PM from hazejean, and for the benefit of others who may have the same problem, I will answer here:button I create buttons dynamically becasue they are different depending on text file being read. this is my code button1 = New Button button1.Location = New Point(1, 18 * (i - 5)) Controls.Add(button1) button1.Text = "SUBMIT" If button1 is clicked I want to output a file to disk. I have tried several way to detect if button is clicked. All have been unsuccessful. Ant ideas.? ThanksTo add a hander to an event dynamically, use the AddHandler function. First create a handler sub with the proper parameters (you can generally get this from the MSDN, or by copying and pasting the params from an existing button). For examplePrivate Sub ButtonClickHandler(sender As Object, e As EventArgs) MessageBox.Show("Click!") End Sub 'to hook up the above hander: AddHandler Button1.Click, AddressOf ButtonClickHanderAs usual, consult the MSDN for more information about handling events. Quote
hazejean Posted September 3, 2003 Author Posted September 3, 2003 thanks thanks Works fine. I was trying to call sub. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.