Click here to Skip to main content
11,432,427 members (65,513 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Windows
hey guys im new in coding and got an quick question hope anyone can help me PLEASE or post something usefull.

is it possible to use this code only with the ckeckbox i mean if checkbox checked enable this code and if checkbox changed disable it.

 
private void button18_Click_1(object sender, EventArgs e)
{
    var pulse = new Thread(health);
    pulse.Start();
}
 
private void health()
{
    do
    {
        _rtm.Poke(0xbE238DD4, "00003A7E");
        if (checkBox1.Checked) Thread.Sleep(500);
    } while (checkBox1.Checked);
    status.Text = "Inf Health Enabled";
}
 
Posted 9-Dec-12 4:33am
Leo Mai339
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

There are two ways to do it:
1) Add code to the Click event handler which looks at your CheckBox.Checked property, and continues only if it is:
private void button18_Click_1(object sender, EventArgs e)
{
    if (myCheckBox.Checked)
    {
        var pulse = new Thread(health);
        Pulse.Start();
    }
}
2) Disable the button by handling the CheckBox.CheckChanged event:
private void myCheckBox_CheckedChanged(object sender, EventArgs e)
{
    button1.Enabled = myCheckBox.Checked;
}
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

thank you, but not exacty that i want.

hmm i want send this code _rtm.Poke(0xbE238DD4, "00003A7E"); permant (like an loop command) using only an checkbox,


edit:

the code i posted is working great as an loop command to send the rtm.poke code
but i will use only the checkbox
  Permalink  
v2
Comments
ProgramFOX at 9-Dec-12 11:18am
   
If you've a comment to an answer, click on the "Have a Question or Comment?" button, but don't post a comment as an answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.150428.2 | Last Updated 9 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100