Event raises but the required code does not?
-
Hi I want to display the message in the following event procidure when a message is received by creating a control dynamically e.g. textbox to display the message. But the control is not created even after the event raises. Where is the bug in my code? Private Sub MessageReceivedEventHandler(ByVal data As String) Handles remote.MessageReceived Dim txt As New TextBox txt.Size = New Size(55, 25) txt.Location = New Point(x, y) txt.Name = "txtServer" txt.Text = data Controls.Add(txt) End Sub Thanks
reman
-
Hi I want to display the message in the following event procidure when a message is received by creating a control dynamically e.g. textbox to display the message. But the control is not created even after the event raises. Where is the bug in my code? Private Sub MessageReceivedEventHandler(ByVal data As String) Handles remote.MessageReceived Dim txt As New TextBox txt.Size = New Size(55, 25) txt.Location = New Point(x, y) txt.Name = "txtServer" txt.Text = data Controls.Add(txt) End Sub Thanks
reman
Won't work reliably is MessageReceivedEventHandler isn't raised on the main thread. Read up on Control.InvokeRequired/Control.Invoke :)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
-
Hi I want to display the message in the following event procidure when a message is received by creating a control dynamically e.g. textbox to display the message. But the control is not created even after the event raises. Where is the bug in my code? Private Sub MessageReceivedEventHandler(ByVal data As String) Handles remote.MessageReceived Dim txt As New TextBox txt.Size = New Size(55, 25) txt.Location = New Point(x, y) txt.Name = "txtServer" txt.Text = data Controls.Add(txt) End Sub Thanks
reman
Don't ask the same question in the same day. Your original post was only 10 hours old. On top of what Luc said, you may also have to check your code to see if your changing the X and/or Y locations appropriately. It may be creating the new TextBoxs (a very inefficient design I might add!) and placing them all in the same location, under the first TextBox that was created.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008