Results 1 to 3 of 3

Thread: deleting from datagrid and displaying contents

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2004
    Posts
    2

    deleting from datagrid and displaying contents

    I have a datagrid and the selected datarows' fields are displayed in fields below.
    When I try to delete a row, then I advance to the next row, the correct row is not shown in the fields below; it tends to lag by one. However, all the records before the record deleted show up fine.
    VB Code:
    1. Private Sub btn_Del_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Del.Click
    2.  
    3.  
    4.         If objDS.Tables("phonebook").Rows.Count > 0 Then
    5.             Dim objDelRow As DataRow
    6.             objDelRow = objDS.Tables("phonebook").Rows(bmGrid.Position)
    7.             objDelRow.Delete()
    8.             moveprevious()
    9.          End If
    10.         ShowRecord(bmGrid.Position)
    11.     End Sub

    Basically my question is there a way to skip through records that are marked as deleted when I scroll through the datagrid?
    this si mah sig! 640k enuf for anyone!!!1111one one har har o_O

  2. #2
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618
    I believe there is a RowState property. Check that for Deleted and deal accordingly....i.e. move to next row.
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

  3. #3
    Lively Member
    Join Date
    Jun 2004
    Location
    Philippines
    Posts
    125
    hi billiam!

    I'm currently looking for a code in deleting records in a datagrid and fortunately, I found yours in this thread. Just wondering, what is the bmgrid in your code? I assumed that it is your datagrid, or not? Cause, when I changed your code to fit my program, it showed an error on the datagrid1.position part... the error is described as position is not a member of 'System.Windows.Forms.Datagrid'...

    I hope you could assist me on this...please do reply soon! Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width