Re: Going into an infinite loop

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Justin Rogers (Justin_at_games4dotnet.com)
Date: 11/03/04


Date: Wed, 3 Nov 2004 12:17:13 -0800

You have loads of checks here. What you might want to do is think about
updating an integer or other value based on some bit ordinal... Something
like the following:

int allBits = 0;
allBits = (allBits << 1) + ((chkColumn.Checked) ? 1 : 0);
allBits = (allBits << 1) + ((chkColumn2.Checked) ? 1 : 0);

When you are done, you need to know how many bits you used. The
reason is you are going to & the value.. Above we added 2 bits, so we'll
use the value of 0x3 (11 in binary).

switch(allBits & 0x3) {
    case 0x0:
        chkAll.Checked = false;
        break;
    case 0x3:
        chkAll.Checked = true;
        break;
    default:
        chkAll.ThreeState = true; chkAll.CheckState = CheckState.Indeterminate;
        break;
}

I'm not testing the above code, so there may be some fixes you need to make, but
the concept is solid enough for you to change your program appropriately...

-- 
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers
"Mark Allison" <marka@no.tinned.meat.mvps.org> wrote in message 
news:ORiF3ncwEHA.3376@TK2MSFTNGP12.phx.gbl...
> Hi,
>
> I'm a DBA learning C#, so am quite green.
>
> I have a form http://www.markallison.co.uk/Images/squealfind2.jpg, on the 
> right there is a group of checkboxes with All Object Types as the header.
>
> Now, when I check All Object Types, all the other checkboxes take on the 
> chkAllObjectTypes check value. Great. What I want to happen is when one of the 
> other check boxes are checked, I want the chkAllObjectTypes checkbox to change 
> state to
>
> 1) Indeterminate (tristate) if all other checkboxes are not the same
> 2) Change to checked, if all other checkboxes are checked
> 3) Change to unchecked, if all other checkboxes are unchecked.
>
> I've pretty much got 2 and 3 covered, I'm having a little trouble with 1. Code 
> snapshot:
> http://paste.mine.nu/Pastebin/Uploads/paste_01144674226.htm
>
> Thanks.
>
> --
> Mark Allison, SQL Server MVP
> http://www.markallison.co.uk
>
> Looking for a SQL Server replication book?
> http://www.nwsu.com/0974973602m.html 


Relevant Pages

  • Re: how to add table and all its index for replication
    ... select teh elipsis button in EM and on the article ... properties, snapshot tab, you'll see the corresponding ... checkboxes. ... Paul Ibison SQL Server MVP, ...
    (microsoft.public.sqlserver.replication)
  • Filter by form problem with Yes/No Data and SQL Server
    ... SQL Server 2005 Back end: ... I have a complex form that has lots of data fields including about ... thirty or so checkboxes storing Yes/No data that I would like my users ... This works perfectly fine when I filter on a text field. ...
    (comp.databases.ms-access)
  • Going into an infinite loop
    ... Now, when I check All Object Types, all the other checkboxes take on the ... of the other check boxes are checked, I want the chkAllObjectTypes ... Looking for a SQL Server replication book? ...
    (microsoft.public.dotnet.languages.csharp)
  • Form error????
    ... I just added two checkboxes on my main form and on the MS SQL server I also ... added two fields as “bit” format. ... "The record has been changed by another user since you started editing it. ... When I delete those two checkboxes it works fine?????? ...
    (microsoft.public.access.forms)
  • Re: default value after replication
    ... AFAIR if you select the checkboxes on the article properties, ... Paul Ibison SQL Server MVP, ...
    (microsoft.public.sqlserver.replication)