Knowledge found and lost while working with Microsoft Dynamics CRM
RSS icon Home icon
  • Rabbits are stupid

    Posted on June 4th, 2006 Mitch Milam Print Print No comments

    So I have this wild rabbit living in my back yard. Mostly because I have grass to eat and no dogs so it doesn't have to worry about being eaten, etc.

    Yesterday morning, while I was making coffee, I looked outside and saw the rabbit nosing around the door to my storage shed.

    Dumbass.

    There's no beer in there.

    Rabbits are stupid.

     

    Meanderings
    1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
    Loading ... Loading ...
    1,422 views
  • Tracking checkboxes in a .NET ListView ( VS2003 )

    Posted on June 4th, 2006 Mitch Milam Print Print No comments

    I encountered a pretty interesting situation this morning as I am working on a utility containing a ListView control in Visual Studio 2003.

    I have a Start button that I would like to be disabled until the user actually selects items from the ListView by clicking on a checkbox associated with the list item. 

    The ListView has a list items collection called .CheckedItems that contains the list of items that have been checked inside the ListView.  The problem surfaces because the update of this collection takes a bit of time and if I am using the .CheckedItems.Count to enable or disable my start button, it will produce a very inconsistent user experience depending on how quickly the user clicks the checkboxes.

    To get around this problem, you actually need to create a variable to store the number items that have been checked. Starting off at zero, of course, and incrementing or decrementing the value each time the user clicks an item's checkbox.

    The code to do this will go into the ItemCheck event, as shown below:

    private void listAvailable_ItemCheck(object sender, System.Windows.Forms.ItemCheckEventArgs e)
    {
         if(e.NewValue==CheckState.Checked)
              iCheckedCount++;
    else
              iCheckedCount–;
         btnStart.Enabled = (iCheckedCount > 0);
      

     

    Hopefully, this will save you a bit of time should need to implement the same practice.

    Development
    1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
    Loading ... Loading ...
    2,348 views