我在面板上方都具有一个宽度相同的宽度325的追踪栏。该追踪栏的最大值为200。在发生鼠标按下事件时,我试图将图像和文本添加到面板上,该图像和文字是一个小点,并垂直对齐轨迹栏箭头。我首先将面板宽度除以200得到位置(左)。 intStepNumber是轨迹栏位置值。结果是图像未与箭头对齐,轨迹栏值越高,偏移量越大。我还添加了10以补偿图像宽度,使其居中。
Private Sub TrackBar_Editor_MouseDown(sender As Object, e As MouseEventArgs) Handles TrackBar_Editor.MouseDown
If e.Button = Windows.Forms.MouseButtons.Right Then
For i = 1 To 5
If int_Tag_used(i) = 0 Then
'// Test all other tab to be sure there is no a duplicate placed.
For J = 1 To 5
If int_Tag_Storage(J) = intStepNumber + 1 Then '// If there is a duplicate exit sub
Exit Sub
End If
Next J
int_Tag_used(i) = 1 '// set the tag as being used
Panel_test.Controls.Add(Picture_Tag(i))
Panel_test.Controls.Add(Label_Tag(i))
int_Width = (Panel_test.Size.Width / 200) '// new for 200
Picture_Tag(i).Left = ((intStepNumber - 1) * int_Width) + 10
Picture_Tag(i).Top = 0
Picture_Tag(i).Visible = True
Label_Tag(i).Left = ((intStepNumber - 1) * int_Width) + 5
Label_Tag(i).Top = 20
Label_Tag(i).Visible = True
Label_Tag(i).Text = intStepNumber + 1 '// Add 1 to alight with trackbar value of 0 to 99
int_Tag_Storage(i) = intStepNumber
Exit For
Else
'// try next
End If
Next i
End If
End Sub