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. Use event on Runtime

Use event on Runtime

Scheduled Pinned Locked Moved Visual Basic
wpfquestion
4 Posts 4 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.
  • I Offline
    I Offline
    ivo75
    wrote on last edited by
    #1

    Hi, I create Pictureboxes on Runtime and I want to use event for these Pictureboxes. How make I this? This is my code

    Dim c As Collection
    Dim myCollection As New Collection()
    c = TwainHandler.ScanImages("C:\", "jpg")
    Dim l As Integer
    l = 0
    Dim i As Integer
    i = 0
    For Each fn1 In c
    i = i + 1
    Next
    If i Mod 2 <> 0 Then
    TableLayoutPanel1.RowCount = i \ 2 + 1
    Else
    TableLayoutPanel1.RowCount = i \ 2
    End If
    TableLayoutPanel1.AutoSizeMode = Windows.Forms.AutoSizeMode.GrowAndShrink
    TableLayoutPanel1.AutoSize = True
    i = 0
    For Each fn In c
    i = i + 1
    Dim lab As New PictureBox
    lab.BringToFront()
    lab.SizeMode = PictureBoxSizeMode.StretchImage
    lab.Size = New Size(100, 100)
    lab.Image = Image.FromFile(fn)
    TableLayoutPanel1.Controls.Add(lab)
    lab.Name = "lab" & i
    Next
    Dim styles As TableLayoutRowStyleCollection = _
    Me.TableLayoutPanel1.RowStyles
    For Each style As RowStyle In styles
    style.Height = 107
    Next

    J J S 3 Replies Last reply
    0
    • I ivo75

      Hi, I create Pictureboxes on Runtime and I want to use event for these Pictureboxes. How make I this? This is my code

      Dim c As Collection
      Dim myCollection As New Collection()
      c = TwainHandler.ScanImages("C:\", "jpg")
      Dim l As Integer
      l = 0
      Dim i As Integer
      i = 0
      For Each fn1 In c
      i = i + 1
      Next
      If i Mod 2 <> 0 Then
      TableLayoutPanel1.RowCount = i \ 2 + 1
      Else
      TableLayoutPanel1.RowCount = i \ 2
      End If
      TableLayoutPanel1.AutoSizeMode = Windows.Forms.AutoSizeMode.GrowAndShrink
      TableLayoutPanel1.AutoSize = True
      i = 0
      For Each fn In c
      i = i + 1
      Dim lab As New PictureBox
      lab.BringToFront()
      lab.SizeMode = PictureBoxSizeMode.StretchImage
      lab.Size = New Size(100, 100)
      lab.Image = Image.FromFile(fn)
      TableLayoutPanel1.Controls.Add(lab)
      lab.Name = "lab" & i
      Next
      Dim styles As TableLayoutRowStyleCollection = _
      Me.TableLayoutPanel1.RowStyles
      For Each style As RowStyle In styles
      style.Height = 107
      Next

      J Offline
      J Offline
      JR212
      wrote on last edited by
      #2

      Take a look at addhandler It's easy

      1 Reply Last reply
      0
      • I ivo75

        Hi, I create Pictureboxes on Runtime and I want to use event for these Pictureboxes. How make I this? This is my code

        Dim c As Collection
        Dim myCollection As New Collection()
        c = TwainHandler.ScanImages("C:\", "jpg")
        Dim l As Integer
        l = 0
        Dim i As Integer
        i = 0
        For Each fn1 In c
        i = i + 1
        Next
        If i Mod 2 <> 0 Then
        TableLayoutPanel1.RowCount = i \ 2 + 1
        Else
        TableLayoutPanel1.RowCount = i \ 2
        End If
        TableLayoutPanel1.AutoSizeMode = Windows.Forms.AutoSizeMode.GrowAndShrink
        TableLayoutPanel1.AutoSize = True
        i = 0
        For Each fn In c
        i = i + 1
        Dim lab As New PictureBox
        lab.BringToFront()
        lab.SizeMode = PictureBoxSizeMode.StretchImage
        lab.Size = New Size(100, 100)
        lab.Image = Image.FromFile(fn)
        TableLayoutPanel1.Controls.Add(lab)
        lab.Name = "lab" & i
        Next
        Dim styles As TableLayoutRowStyleCollection = _
        Me.TableLayoutPanel1.RowStyles
        For Each style As RowStyle In styles
        style.Height = 107
        Next

        J Offline
        J Offline
        Johan Hakkesteegt
        wrote on last edited by
        #3

        You could create a windows form object with just an empty PictureBox on it, and write the event handling in that objects code. Then instead of creating PictureBox objects you create these forms. That way you can use Visual Studio the normal way for the look and event handling of your picture objects.

        My advice is free, and you may get what you paid for.

        1 Reply Last reply
        0
        • I ivo75

          Hi, I create Pictureboxes on Runtime and I want to use event for these Pictureboxes. How make I this? This is my code

          Dim c As Collection
          Dim myCollection As New Collection()
          c = TwainHandler.ScanImages("C:\", "jpg")
          Dim l As Integer
          l = 0
          Dim i As Integer
          i = 0
          For Each fn1 In c
          i = i + 1
          Next
          If i Mod 2 <> 0 Then
          TableLayoutPanel1.RowCount = i \ 2 + 1
          Else
          TableLayoutPanel1.RowCount = i \ 2
          End If
          TableLayoutPanel1.AutoSizeMode = Windows.Forms.AutoSizeMode.GrowAndShrink
          TableLayoutPanel1.AutoSize = True
          i = 0
          For Each fn In c
          i = i + 1
          Dim lab As New PictureBox
          lab.BringToFront()
          lab.SizeMode = PictureBoxSizeMode.StretchImage
          lab.Size = New Size(100, 100)
          lab.Image = Image.FromFile(fn)
          TableLayoutPanel1.Controls.Add(lab)
          lab.Name = "lab" & i
          Next
          Dim styles As TableLayoutRowStyleCollection = _
          Me.TableLayoutPanel1.RowStyles
          For Each style As RowStyle In styles
          style.Height = 107
          Next

          S Offline
          S Offline
          Simon_Whale
          wrote on last edited by
          #4

          have a look at the addhandler fuction Addhandler[^]

          Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch

          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