Datagrid And Checkbox


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Datagrid And Checkbox

  1. #1
    Join Date
    Mar 2005
    Posts
    110

    Datagrid And Checkbox

    HI,

    How to make the arrowpart(which the arrow is on) of datagrid contol turn into the checkbox?

    Acutually, data is retrieved from database and showed in the datagrid. I want to add a checkbox option to every row in the datagrid , so the end user can click the checkbox to select the row ,based on the selected rows, I update database.

    I have no ideas to implement it. if it won't work, what should I do to select more data from datagrid ?

    thanks any help.

  2. #2
    Join Date
    Jan 2004
    Location
    Alexandria, VA
    Posts
    392
    I normally us the MSFlexGrid control, but what I do is create a checkbox array, and dynamically size it according to the number of rows.

    I've attached a project (still in progress) that shows this in very simple terms...
    Attached Files Attached Files
    Bob Rouse
    Dimension Data

  3. #3
    Join Date
    Mar 2005
    Posts
    110
    Thanks Bob

    I tried your code .It is very good. But I have another question about your code. how to scroll the checkbox array when the Msflexgrid is scrolling?

    Thanks again

  4. #4
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    I toss my two cents here.
    I use another tecnique. I created two icons, a checkOn and checkOff, that I load in two Image controls, and I display them in the grid using the CellPicture property. In the mouse down event, I check if the mouse is on the picture, and if yes I switch the picture to On to Off and viceversa. I use the RowData propert to reflect the state of the check box for each row. I am saying this is better...
    Marco
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  5. #5
    Join Date
    Jan 2004
    Location
    Alexandria, VA
    Posts
    392
    I'll agree with Marco that his is better for a simple on/off check. For mine, I needed that 3rd state of "grayed", and it needed to really look and act like a checkbox control.

    Scrolling (and column resizing) are a problem and require some coding fun. For scrolling, you have to put code in the "Scroll" event (if you have a lot of stuff in the grid list, it can get pretty ugly). For column resize there is no event. I had to use a timer and force a repaint (also ugly. I could have subclassed it, but we will be switching to .NET in a few months, so I went with the easier workaround).
    Bob Rouse
    Dimension Data

  6. #6
    Join Date
    Mar 2005
    Posts
    110
    Thanks .

    I did it with mstraf'way.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center