0
我有以下代碼,可以對位於表格內的圖片框進行圖片翻轉。每個表格單元格中都有一個圖片框。C#工具提示問題
問題是即使在代碼中聲明不應該顯示圖片框上的工具提示,不知何故某些工具提示出現。我不能在代碼中找到它,因爲代碼沒有指定任何工具提示!
我已經嘗試了幾種方法,但他們似乎都使用工具提示collasp ..是否有工具提示控件中的已知錯誤?
private bool deployingShip = false;
private void PictureBox_MouseEnter(object sender, EventArgs e)
{
PictureBox HomeCurrentPicBox = ((PictureBox)(sender));
TableLayoutPanelCellPosition HomeCurrentPosition = HomeTableLayoutPanel.GetCellPosition(HomeCurrentPicBox);
RefreshHomeGrid();
if (deployingShip == false)
{
if (GameModel.HomeCellStatus(HomeCurrentPosition.Column, HomeCurrentPosition.Row) == Cell.cellState.Water)
{
HomeTableLayoutPanel.Cursor = Cursors.Hand;
HomeCurrentPicBox.Image = Properties.Resources.Scan;
HomeCurrentPicBox.Refresh();
}
else
{
HomeTableLayoutPanel.Cursor = Cursors.No;
HomeTableLayoutPanel.Refresh();
}
gameFormToolTip.SetToolTip(HomeCurrentPicBox, GameModel.alphaCoords(HomeCurrentPosition.Column) + "," + HomeCurrentPosition.Row);
}
if (deployingShip == true)
{
Cell.cellState state = GameModel.HomeCellStatus(HomeCurrentPosition.Column, HomeCurrentPosition.Row);
switch (state)
{
case Cell.cellState.Origin:
HomeTableLayoutPanel.Cursor = Cursors.Hand;
gameFormToolTip.SetToolTip(HomeCurrentPicBox, currentShip.ToString() + ": " + Cell.cellState.Origin);
break;
case Cell.cellState.EndPoint:
HomeTableLayoutPanel.Cursor = Cursors.Hand;
gameFormToolTip.SetToolTip(HomeCurrentPicBox, currentShip.ToString() + ": " + Cell.cellState.EndPoint);
break;
default:
HomeTableLayoutPanel.Cursor = Cursors.No;
HomeTableLayoutPanel.Refresh();
return;
}
}
}
private void PictureBox_MouseLeave(object sender, EventArgs e)
{
PictureBox HomeCurrentPicBox = ((PictureBox)(sender));
TableLayoutPanelCellPosition HomeCurrentPosition = HomeTableLayoutPanel.GetCellPosition(HomeCurrentPicBox);
if (GameModel.HomeCellStatus(HomeCurrentPosition.Column, HomeCurrentPosition.Row) == Cell.cellState.Water)
{
HomeCurrentPicBox.Image = Properties.Resources.Water;
HomeCurrentPicBox.Refresh();
}
}
謝謝你,我怕你將無法從該提交的代碼:(找到了這個錯誤
測試吧!謝謝你把SetToolTip行爲的清晰度!就是這樣。感謝很多很多次。 – iTEgg
它總是竊聽我,工具提示沒有按」 t有一個明確的命令,而且,不應該是'String.Empty'? – Powerlord
是的,我使用string.empty,但約翰L.提供了一個堅實的解決方案。 – iTEgg