Hello Guys,
I am trying to mark locations on a map (x,y pixels are derived from a DB)
This is the code that i am using
And this is the Error that Occurs
System.Argument Exception was caught
Message="Contro ls created on one thread cannot be parented to a control on a different thread."
Source="System. Windows.Forms"
StackTrace:
at System.Windows. Forms.Control.C ontrolCollectio n.Add(Control value)
at System.Windows. Forms.Form.Cont rolCollection.A dd(Control value)
at RoundTrip.frmRo undTrip.DrowLab el(Int64 X, Int64 Y, String lblText)
--
The purpose of this code is to mark locations on a map,
I would be glad: if you help me finding the solution or any other solution which fits my needs
Regards
Ramy
I am trying to mark locations on a map (x,y pixels are derived from a DB)
This is the code that i am using
Code:
Private Sub DisplayOnSoftMap() SqlQuey = "Select * FROM SoftwareMap WHERE SoftwareMap.SMSID =myRndTrip.CurrentSwitch.SID & "'" tmpSoftMapCol = tmpSoftMapCol.GetAllSoftwareMap(SqlQuey) For Each tmpSoftMap In tmpSoftMapCol DrowLabel(tmpSoftMap.XMap, tmpSoftMap.YMap, tmpSoftMap.LablName) next Private Sub DrowLabel(ByVal X As Long, ByVal Y As Long, ByVal lblText As String) Dim LIndex, Lcount As Integer Try If Lbl Is Nothing Then ReDim Preserve Lbl(0) Lcount = 1 LIndex = 0 Else Lcount = Lbl.Length ReDim Preserve Lbl(Lcount) LIndex = Lcount End If Lbl(LIndex) = New LinkLabel Control.CheckForIllegalCrossThreadCalls = False Lbl(LIndex).Location = New System.Drawing.Point(X, Y) Lbl(LIndex).Text = lblText Lbl(LIndex).Visible = True Lbl(LIndex).AutoSize = True Control.CheckForIllegalCrossThreadCalls = False Me.Controls.Add(Lbl(LIndex)) AddHandler Lbl(LIndex).Click, AddressOf Label_Click Catch ex As Exception Throw ex End Try End Sub
System.Argument Exception was caught
Message="Contro ls created on one thread cannot be parented to a control on a different thread."
Source="System. Windows.Forms"
StackTrace:
at System.Windows. Forms.Control.C ontrolCollectio n.Add(Control value)
at System.Windows. Forms.Form.Cont rolCollection.A dd(Control value)
at RoundTrip.frmRo undTrip.DrowLab el(Int64 X, Int64 Y, String lblText)
--
The purpose of this code is to mark locations on a map,
I would be glad: if you help me finding the solution or any other solution which fits my needs
Regards
Ramy
Comment