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. problem with collection and user control.., Please Help.

problem with collection and user control.., Please Help.

Scheduled Pinned Locked Moved Visual Basic
helpcsharp
2 Posts 1 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.
  • R Offline
    R Offline
    Rajesh Anuhya
    wrote on last edited by
    #1

    am developing an application using vb.net, i created a user control which used in the another application. am passing parameters to the user control using public properties from files. i specified a folder , when a new file is created in the folder. in the timer control code am adding the new user control dynamically if the usercontrol is not exists, if it's already exists am updation the values. problem is when am updation the one usercontrol. the total usercontrols values are changing (as like reference), but am creating new instants every time. Here is the code : Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Timer1.Enabled = False Try Dim Files As String() = Directory.GetFiles(Application.StartupPath & "\data") Dim Filename As String For Each Filename In Files Dim line As String Using sr As StreamReader = New StreamReader(Filename) line = sr.ReadToEnd End Using Dim cntrllop As Integer, cntlflg As Boolean = False For cntrllop = 1 To mycontrolcoll.Count If (UCase(mycontrolcoll.Item(cntrllop).Name) = UCase(Split(Filename, "\")(Split(Filename, "\").Length - 1))) Then parse_data(mycontrolcoll.Item(cntrllop), line, Filename) cntlflg = True End If Next If cntlflg = False Then SyncLock mycontrolcoll mycontrolcoll.Add(New UserControl1, UCase(Split(Filename, "\")(Split(Filename, "\").Length - 1)), Nothing, Nothing) mycontrolcoll.Item(mycontrolcoll.Count).name = UCase(Split(Filename, "\")(Split(Filename, "\").Length - 1)) FlowLayoutPanel1.Controls.Add(mycontrolcoll.Item(mycontrolcoll.Count)) parse_data(mycontrolcoll.Item(mycontrolcoll.Count), line, Filename) End SyncLock End If 'My.Computer.FileSystem.DeleteFile(Filename) Next Catch ex As Exception MsgBox(ex.Message) End Try Timer1.Enabled = True End Sub Private Sub parse_data(ByRef MYcontrol As CAMR_Control.UserControl1, ByVal data As String, ByVal filename As String) MYcontrol.Name = Mid(Split(data, ",")(0), 2) MYcontrol.Pow_ctrlstart = True MYco

    R 1 Reply Last reply
    0
    • R Rajesh Anuhya

      am developing an application using vb.net, i created a user control which used in the another application. am passing parameters to the user control using public properties from files. i specified a folder , when a new file is created in the folder. in the timer control code am adding the new user control dynamically if the usercontrol is not exists, if it's already exists am updation the values. problem is when am updation the one usercontrol. the total usercontrols values are changing (as like reference), but am creating new instants every time. Here is the code : Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Timer1.Enabled = False Try Dim Files As String() = Directory.GetFiles(Application.StartupPath & "\data") Dim Filename As String For Each Filename In Files Dim line As String Using sr As StreamReader = New StreamReader(Filename) line = sr.ReadToEnd End Using Dim cntrllop As Integer, cntlflg As Boolean = False For cntrllop = 1 To mycontrolcoll.Count If (UCase(mycontrolcoll.Item(cntrllop).Name) = UCase(Split(Filename, "\")(Split(Filename, "\").Length - 1))) Then parse_data(mycontrolcoll.Item(cntrllop), line, Filename) cntlflg = True End If Next If cntlflg = False Then SyncLock mycontrolcoll mycontrolcoll.Add(New UserControl1, UCase(Split(Filename, "\")(Split(Filename, "\").Length - 1)), Nothing, Nothing) mycontrolcoll.Item(mycontrolcoll.Count).name = UCase(Split(Filename, "\")(Split(Filename, "\").Length - 1)) FlowLayoutPanel1.Controls.Add(mycontrolcoll.Item(mycontrolcoll.Count)) parse_data(mycontrolcoll.Item(mycontrolcoll.Count), line, Filename) End SyncLock End If 'My.Computer.FileSystem.DeleteFile(Filename) Next Catch ex As Exception MsgBox(ex.Message) End Try Timer1.Enabled = True End Sub Private Sub parse_data(ByRef MYcontrol As CAMR_Control.UserControl1, ByVal data As String, ByVal filename As String) MYcontrol.Name = Mid(Split(data, ",")(0), 2) MYcontrol.Pow_ctrlstart = True MYco

      R Offline
      R Offline
      Rajesh Anuhya
      wrote on last edited by
      #2

      OK i got it... :cool::cool::cool::cool:

      Rajesh B --> A Poor Workman Blames His Tools <--

      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