2012-10-05 26 views
-1

我正在用Picturebox填充FlowLayout。當我填充時,我給他們每個人一個工具提示。我有一個單獨的功能來更改圖片我怎樣才能改變工具提示?如何只更改一個工具提示?

dim laytt as tooltip = new tooltip 

For i = 1 To count 
     Dim newPic As PictureBox = New PictureBox() 
     newPic.Image = p.Image 
     newPic.Size = p.Size 
     newPic.SizeMode = p.SizeMode 

     laytt.SetToolTip(newPic, ttstring) 

     AddHandler newPic.Click, AddressOf LayoutComponent_Clicked 

     sys.Add(a_component) 

     LayoutFlowLayout.Controls.Add(newPic) 
Next 

後來我有一個函數來改變圖片的它,我希望能夠改變刀尖

Private Sub LayoutComponent_Clicked(ByVal sender As Object, ByVal e As EventArgs) 

    Dim i As Integer = LayoutFlowLayout.Controls.IndexOf(sender) 

    If deleteModeOn Then 
     sys.components.RemoveAt(i) 
     LayoutFlowLayout.Controls.RemoveAt(i) 
     Exit Sub 
    End If 

    'get index in sys from layout? 


    If (sys.components.Item(i).GetType() = GetType(Transpositor)) Then 
     Form2.ShowDialog(Me) 
     sys.components.Item(i).divert = tempTranspositorDivert 

     'here I want to do something like this 
     laytt.RemoveAt(i) <--- THIS DOESN'T EXIST 

    End If 

End Sub 

TL; DR我想刪除/在改變只有一個提示文本特定索引

回答

2

由於sender參數是單擊的圖片框控件,因此可以使用該變量指定要更改的控件。例如,這將刪除工具提示:

laytt.SetToolTip(sender, Nothing) 

這將改變它:

laytt.SetToolTip(sender, "new value") 
+0

沒有這實際上增加了一個新的工具提示。所以在這一點上,我會有2個工具提示在同一個發件人。 不可思議吧? – Ervin

+0

它不應該根據MSDN,它並沒有在我的快速測試中添加另一個。 –

+0

你是對的。我胖了第一次!謝謝! – Ervin