Find the state of checkbox in datagridview

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sajjeelhassan
    New Member
    • Dec 2007
    • 1

    Find the state of checkbox in datagridview

    hi
    can any one tell

    i found a problem ...while during work on datagridview

    checkbox is in the 2nd column of the datagridview having header "REGISTER" and
    a textbox in the 1st column of the datagridview having header "NAME"...
    i want to select those names whome corresponding checkbox is checked..


    i want to get the state of check box whether it is checked or not....

    i tried this but this wouldnt work
    if ((bool)dataGrid View1.Rows[i].Cells[2].Value == true)
    can any one help me within 1 day......i'lll b thankful to u
  • giveDsolution
    New Member
    • May 2007
    • 107

    #2
    May it help u,(It works for Gridview)

    First find the checkbox usiing loop of rows in datagrid.
    Then check that row ,,,checkbox .checked=true
    If True then find the value of textbox in that same row
    else continue the loop

    Comment

    • PareshRathod
      New Member
      • Mar 2007
      • 28

      #3
      It is little bit hard to understand... try this simple one.
      For e.g. you datagrid's id is dgMain and column 1 is checkbox column and you want to find the state of checkbox of datagrid row number 6 then
      (VB.NET syntax)
      Dim chk As CheckBox = DirectCast(dgMa in.Items(6).Cel ls(0).Controls( 1), CheckBox)
      if (chk.checked) then
      'Implement true logic
      else
      'Implement false logic
      end if

      Hope this will help you...

      Paresh

      Originally posted by giveDsolution
      May it help u,(It works for Gridview)

      First find the checkbox usiing loop of rows in datagrid.
      Then check that row ,,,checkbox .checked=true
      If True then find the value of textbox in that same row
      else continue the loop

      Comment

      Working...