Click here to Skip to main content
15,892,005 members
Home / Discussions / C#
   

C#

 
GeneralRe: Cross-Threading problem, InvokeRequired and Events Pin
Luc Pattyn16-Feb-10 9:45
sitebuilderLuc Pattyn16-Feb-10 9:45 
GeneralRe: Cross-Threading problem, InvokeRequired and Events Pin
User 680178016-Feb-10 10:02
User 680178016-Feb-10 10:02 
GeneralRe: Cross-Threading problem, InvokeRequired and Events Pin
User 680178016-Feb-10 10:09
User 680178016-Feb-10 10:09 
GeneralRe: Cross-Threading problem, InvokeRequired and Events Pin
User 680178017-Feb-10 7:05
User 680178017-Feb-10 7:05 
AnswerRe: Cross-Threading problem, InvokeRequired and Events Pin
#realJSOP15-Feb-10 23:21
mve#realJSOP15-Feb-10 23:21 
GeneralRe: Cross-Threading problem, InvokeRequired and Events Pin
User 680178019-Feb-10 4:10
User 680178019-Feb-10 4:10 
GeneralRe: Cross-Threading problem, InvokeRequired and Events Pin
User 680178019-Feb-10 8:06
User 680178019-Feb-10 8:06 
QuestionC# TableLayoutPanel MouseLeave Pin
ikurtz15-Feb-10 5:27
ikurtz15-Feb-10 5:27 
greetings, i am developing a battleships clone game and i have an issue with TableLayoutPanel MouseLeave event.

first MouseMove:

private PictureBox HomeLastPicBox = new PictureBox(); 
 
    private TableLayoutPanelCellPosition homeLastPosition = new TableLayoutPanelCellPosition(0, 0); 
 
    private void HomeTableLayoutPanel_MouseMove(object sender, MouseEventArgs e) 
    { 
 
        PictureBox NowPicControl = (PictureBox)(HomeTableLayoutPanel.GetChildAtPoint(e.Location)); 
 
        if ((NowPicControl != null) && (NowPicControl != HomeLastPicBox)) 
        { 
 
            HomeLastPicBox = (PictureBox)(HomeTableLayoutPanel.GetControlFromPosition(homeLastPosition.Column, homeLastPosition.Row)); 
 
            if (GameModel.HomeCellStatus(homeLastPosition.Column, homeLastPosition.Row) == Cell.cellState.WATER) 
            { 
                HomeLastPicBox.Image = Properties.Resources.water; 
            } 
 
            TableLayoutPanelCellPosition homeCurrentPosition = HomeTableLayoutPanel.GetCellPosition(NowPicControl); 
 
            if (GameModel.HomeCellStatus(homeCurrentPosition.Column, homeCurrentPosition.Row) == Cell.cellState.WATER) 
            { 
                NowPicControl.Image = Properties.Resources.scan; 
            } 
            homeLastPosition = homeCurrentPosition; 
        } 
    } 


this appears to function properly.

now the MouseLeave event:

 private void HomeTableLayoutPanel_MouseLeave(object sender, EventArgs e)
{
    MessageBox.Show("col " + homeLastPosition.Column.ToString() + " row " + homeLastPosition.Row.ToString());
    if (GameModel.HomeCellStatus(homeLastPosition.Column, homeLastPosition.Row) == Cell.cellState.WATER)
    {
        HomeLastPicBox.Image = Properties.Resources.water;
        MessageBox.Show("hi");
    }
    HomeLastPicBox = new PictureBox();
}


this is acting strange. it goes through the code and even a "HI" is displayed but the PictureBox image is not changed to water. any ideas as to why? this does not happen all the time, only from time to time.

what the above code is doing is basically scanning through the table cells and if the cell content is WATER then it updates the table cell image to SCAN and as the user moves onwards it is switching the cell image back to WATER.

hope this is enough information. please ask if more is needed.

thank you in advance.
AnswerRe: C# TableLayoutPanel MouseLeave Pin
AhsanS15-Feb-10 5:48
AhsanS15-Feb-10 5:48 
GeneralRe: C# TableLayoutPanel MouseLeave Pin
ikurtz15-Feb-10 6:21
ikurtz15-Feb-10 6:21 
QuestionProblem using a class Pin
msg5512115-Feb-10 4:59
msg5512115-Feb-10 4:59 
AnswerRe: Problem using a class Pin
vaghelabhavesh15-Feb-10 5:04
vaghelabhavesh15-Feb-10 5:04 
GeneralRe: Problem using a class Pin
msg5512115-Feb-10 5:31
msg5512115-Feb-10 5:31 
GeneralRe: Problem using a class Pin
vaghelabhavesh15-Feb-10 5:53
vaghelabhavesh15-Feb-10 5:53 
QuestionIP Address Pin
sanforjackass15-Feb-10 4:16
sanforjackass15-Feb-10 4:16 
AnswerRe: IP Address Pin
Migounette15-Feb-10 4:18
Migounette15-Feb-10 4:18 
GeneralRe: IP Address Pin
sanforjackass15-Feb-10 4:43
sanforjackass15-Feb-10 4:43 
GeneralRe: IP Address Pin
Dave Kreskowiak15-Feb-10 5:46
mveDave Kreskowiak15-Feb-10 5:46 
AnswerRe: IP Address Pin
Som Shekhar15-Feb-10 5:55
Som Shekhar15-Feb-10 5:55 
GeneralRe: IP Address Pin
sanforjackass15-Feb-10 9:20
sanforjackass15-Feb-10 9:20 
GeneralRe: IP Address Pin
Som Shekhar15-Feb-10 18:04
Som Shekhar15-Feb-10 18:04 
GeneralRe: IP Address Pin
sanforjackass15-Feb-10 21:37
sanforjackass15-Feb-10 21:37 
GeneralRe: IP Address Pin
Som Shekhar15-Feb-10 21:39
Som Shekhar15-Feb-10 21:39 
GeneralMessage Removed Pin
15-Feb-10 22:06
sanforjackass15-Feb-10 22:06 
GeneralRe: IP Address Pin
Som Shekhar15-Feb-10 22:08
Som Shekhar15-Feb-10 22:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.