Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Event raises but the required code does not?

Event raises but the required code does not?

Scheduled Pinned Locked Moved Visual Basic
helpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Amer Rehman 0
    wrote on last edited by
    #1

    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

    L D 2 Replies Last reply
    0
    • A Amer Rehman 0

      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

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      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.


      1 Reply Last reply
      0
      • A Amer Rehman 0

        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

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups