Click here to Skip to main content
15,914,905 members
Home / Discussions / C#
   

C#

 
AnswerRe: Multithreaded splash form causing weird problems. Need help, code inlcuded. Pin
Judah Gabriel Himango11-May-06 9:31
sponsorJudah Gabriel Himango11-May-06 9:31 
GeneralRe: Multithreaded splash form causing weird problems. Need help, code inlcuded. Pin
LongRange.Shooter13-May-06 5:13
LongRange.Shooter13-May-06 5:13 
GeneralRe: Multithreaded splash form causing weird problems. Need help, code inlcuded. Pin
Office Lineman12-May-06 23:03
Office Lineman12-May-06 23:03 
GeneralRe: Multithreaded splash form causing weird problems. Need help, code inlcuded. Pin
LongRange.Shooter13-May-06 5:14
LongRange.Shooter13-May-06 5:14 
QuestionDynamically load DLL class to the project Pin
Virtek11-May-06 6:37
Virtek11-May-06 6:37 
AnswerRe: Dynamically load DLL class to the project Pin
LongRange.Shooter11-May-06 6:49
LongRange.Shooter11-May-06 6:49 
GeneralRe: Dynamically load DLL class to the project Pin
Virtek11-May-06 8:00
Virtek11-May-06 8:00 
QuestionBinding a checkbox to a bool? Pin
iswoolley11-May-06 5:53
iswoolley11-May-06 5:53 
Apologies for the really noob question, but here goes:

I want to make a boolean field in my homespun class available, so that I can link a Checkbox (or multiple checkboxes) to it. I'm not sure what the proper terminology for this link is, maybe data binding?

Here's the source of my class;

class ToggleClass<br />
{<br />
  private bool value;<br />
<br />
  public bool Value<br />
  {<br />
    get { return value; }<br />
  }<br />
<br />
  public ToggleClass ()<br />
  {<br />
    value=false;<br />
  }<br />
<br />
  public void Toggle ()<br />
  {<br />
    while(true)<br />
    {<br />
    value=!value;<br />
    Thread.Sleep(1000);<br />
    }<br />
  }<br />
}


An application would create an instance of the ToggleClass, and then create a new thread and start the Toggle() method going.

ToggleClass obj=new ToggleClass();<br />
Thread thread=new Thread(new ThreadStart(obj.Toggle));<br />
thread.Start();


Now I assume that I can use

obj.Value

to read the current state of the boolean.

I'm using the C# Express development environment, so I've created a Form, put a Checkbox on it, and then linked my ToggleClass as a data source, so that I can set the DataBindings property of the Checkbox to the Value field of the ToggleClass class.

checkbox1.DataBindings.Add(new Binding("Checked",ToggleClass,"Value",true));

I suspect that I'm missing some way of notifying the Checkbox(es) that the value of the boolean has changed. So that's my question, what else do I need to implement such that the Checkbox will reflect the current value of the bool field? Should I be throwing an event, which the Checkbox(es) catches?

Alternatively, if I'm barking up the wrong tree to get this type of job done, please tell me which tree I should be barking up.

Thanks, Iain.
AnswerRe: Binding a checkbox to a bool? Pin
J4amieC11-May-06 6:03
J4amieC11-May-06 6:03 
GeneralRe: Binding a checkbox to a bool? Pin
iswoolley11-May-06 7:16
iswoolley11-May-06 7:16 
QuestionOnly able to print once? Pin
melanieab11-May-06 5:33
melanieab11-May-06 5:33 
AnswerRe: Only able to print once? Pin
LongRange.Shooter11-May-06 6:56
LongRange.Shooter11-May-06 6:56 
GeneralRe: Only able to print once? Pin
melanieab11-May-06 9:15
melanieab11-May-06 9:15 
GeneralRe: Only able to print once? Pin
melanieab12-May-06 6:05
melanieab12-May-06 6:05 
GeneralRe: Only able to print once? Pin
Martin#16-Nov-06 22:57
Martin#16-Nov-06 22:57 
Questionoverrride onpaint Pin
Sasuko11-May-06 4:27
Sasuko11-May-06 4:27 
AnswerRe: overrride onpaint Pin
Ravi Bhavnani11-May-06 4:55
professionalRavi Bhavnani11-May-06 4:55 
AnswerRe: overrride onpaint Pin
leppie11-May-06 7:52
leppie11-May-06 7:52 
QuestionWhy doesn't my code crash? Passing Int64 to Int32 Pin
nicknotyet11-May-06 4:07
nicknotyet11-May-06 4:07 
AnswerRe: Why doesn't my code crash? Passing Int64 to Int32 Pin
Judah Gabriel Himango11-May-06 5:22
sponsorJudah Gabriel Himango11-May-06 5:22 
GeneralRe: Why doesn't my code crash? Passing Int64 to Int32 Pin
nicknotyet11-May-06 5:54
nicknotyet11-May-06 5:54 
GeneralRe: Why doesn't my code crash? Passing Int64 to Int32 Pin
Judah Gabriel Himango11-May-06 5:59
sponsorJudah Gabriel Himango11-May-06 5:59 
GeneralRe: Why doesn't my code crash? Passing Int64 to Int32 Pin
led mike11-May-06 6:21
led mike11-May-06 6:21 
GeneralRe: Why doesn't my code crash? Passing Int64 to Int32 Pin
nicknotyet11-May-06 11:44
nicknotyet11-May-06 11:44 
GeneralRe: Why doesn't my code crash? Passing Int64 to Int32 Pin
Matt Newman11-May-06 19:26
Matt Newman11-May-06 19:26 

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.