problem with collection and user control.., Please Help.
-
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
-
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
OK i got it... :cool::cool::cool::cool:
Rajesh B --> A Poor Workman Blames His Tools <--