Click here to Skip to main content
15,889,867 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all,

I want to delete rows from a mshflexgrid.
I am using mshflexgrid1.removeitem, It acts fine but after deleting a row the mshflexgrid.rows does not decreases by 1 for a deleting row.
Thanks for any suggestions to deleting entire row with row count.

regards sahu

Let me explain it briefly.
procedure for add items to mshflexgrid acts properly for entry
procedure for remove items to mshflexgrid also deletes the row required
The problem is that when we delete a single row after that if i inserts a row it does not works for once then ok and the row number in first cell increases to 2. These r my 2 procedures

VB
'procedure for add items to mshflexgrid

private sub cmdinsert_click()
    GrdPurchage.Rows = GrdPurchage.Rows + 1
    GrdPurchage.TextMatrix(GrdPurchage.Rows - 1, 0) = GrdPurchage.Rows - 1
    GrdPurchage.TextMatrix(GrdPurchage.Rows - 1, 1) = buyer
    GrdPurchage.TextMatrix(GrdPurchage.Rows - 1, 2) = seller
    GrdPurchage.TextMatrix(GrdPurchage.Rows - 1, 3) = storage
    GrdPurchage.TextMatrix(GrdPurchage.Rows - 1, 4) = Item
    GrdPurchage.TextMatrix(GrdPurchage.Rows - 1, 5) = txtqty.Text
end sub


' procedure for delete items
Private Sub cmddelete_Click()
If rownum > 0 Then

Debug.Print GrdPurchage.Rows
GrdPurchage.RemoveItem (rownum)   '(GrdPurchage.RowSel)
DoEvents
Debug.Print GrdPurchage.Rows
end sub
plz help me, other suggestions would be welcome
Posted
Updated 24-Oct-11 3:07am
v3
Comments
Marc A. Brown 24-Oct-11 9:11am    
I'm don't understand what you mean by the sentence "The problem is that when we delete a single row after that if i inserts a row it does not works for once then ok and the row number in first cell increases to 2."
Can you clarify? Also, what do you get from the two Debug.Print calls in your delete code?

1 solution

After calling RemoveItem, you could set the Rows property to Rows-1.
 
Share this answer
 
Comments
Sahu.Ashok 21-Oct-11 14:42pm    
Thanks Marc, but sorry for saying it deletes another row from the grid.
Marc A. Brown 21-Oct-11 14:51pm    
Hmm. Are you sure then that Rows isn't getting updated after the RemoveItem call? You probably already know this, but you can find out by putting a Debug.Print mshflexgrid1.Rows before the call to mshflexgrid1.RemoveItem and another Debug.Print mshflexgrid1.Rows after the call. I hate to suggest it because it may just act as a cover-up for another ill, but you could also insert a DoEvents immediately after the call to RemoveItem (before the second Debug.Print I recommended).
Sahu.Ashok 22-Oct-11 3:38am    
plz see the updated question and try to suggest me. Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900