greetings, im trying to implement an image rollover on a collection of PictureBox (es) that are place in a tablelayoutpanel and one in each table cell.
here is my code:
HomePicBox[picBoxCount].MouseEnter += new System.EventHandler(this.PictureBox_MouseEnter);
HomePicBox[picBoxCount].MouseLeave += new System.EventHandler(this.PictureBox_MouseLeave);
==================
private void PictureBox_MouseEnter(object sender, EventArgs e)
{
Point p = HomeTableLayoutPanel.PointToClient(Control.MousePosition);
PictureBox HomeCurrentPicBox = (PictureBox)(HomeTableLayoutPanel.GetChildAtPoint(p));
if (HomeCurrentPicBox == null)
return;
TableLayoutPanelCellPosition HomeCurrentPosition = HomeTableLayoutPanel.GetCellPosition(HomeCurrentPicBox);
if (GameModel.HomeCellStatus(HomeCurrentPosition.Column, HomeCurrentPosition.Row) == Cell.cellState.Water)
{
HomeCurrentPicBox.Image = Properties.Resources.Scan;
HomeCurrentPicBox.Refresh();
gameFormToolTip.SetToolTip(HomeCurrentPicBox, GameModel.alphaCoords(HomeCurrentPosition.Column) + "," + HomeCurrentPosition.Row);
}
}
private void PictureBox_MouseLeave(object sender, EventArgs e)
{
Point p = HomeTableLayoutPanel.PointToClient(Control.MousePosition);
PictureBox HomeCurrentPicBox = (PictureBox)(HomeTableLayoutPanel.GetChildAtPoint(p));
if (HomeCurrentPicBox == null)
return;
TableLayoutPanelCellPosition HomeCurrentPosition = HomeTableLayoutPanel.GetCellPosition(HomeCurrentPicBox);
if (GameModel.HomeCellStatus(HomeCurrentPosition.Column, HomeCurrentPosition.Row) == Cell.cellState.Water)
{
HomeCurrentPicBox.Image = Properties.Resources.Water;
HomeCurrentPicBox.Refresh();
gameFormToolTip.SetToolTip(HomeCurrentPicBox, GameModel.alphaCoords(HomeCurrentPosition.Column) + "," + HomeCurrentPosition.Row);
}
}
but the rollover is not working! any ideas as to how to implement this correctly?
thanks in advance.
the following:
private void PictureBox_MouseEnter(object sender, EventArgs e)
{
PictureBox HomeCurrentPicBox = ((PictureBox)(sender));
HomeCurrentPicBox.Image = Properties.Resources.Scan;
TableLayoutPanelCellPosition HomeCurrentPosition = HomeTableLayoutPanel.GetCellPosition(HomeCurrentPicBox);
gameFormToolTip.SetToolTip(HomeTableLayoutPanel, GameModel.alphaCoords(HomeCurrentPosition.Column) + "," + HomeCurrentPosition.Row);
}
private void PictureBox_MouseLeave(object sender, EventArgs e)
{
PictureBox HomeCurrentPicBox = ((PictureBox)(sender));
HomeCurrentPicBox.Image = Properties.Resources.Water;
TableLayoutPanelCellPosition HomeCurrentPosition = HomeTableLayoutPanel.GetCellPosition(HomeCurrentPicBox);
gameFormToolTip.SetToolTip(HomeTableLayoutPanel, GameModel.alphaCoords(HomeCurrentPosition.Column) + "," + HomeCurrentPosition.Row);
}
it does the image rollover right but does not display the tooltip. if i state HomeCurrentPicBox instead of HomeTableLayoutPanel on the tooltip it diplays wrongly.
okay no it works i think. i had to change the AutomaticDelay value of the tooltip.
thanks everyone.