VB6 Datagrid - deleting and selecting rows

Posted on 2002-05-08
Medium Priority
Last Modified: 2008-01-16
I am using a datagrid in my VB6 application. I am looking for code to actually delete a row or make it invisible, I dont want to delete the record from the database . All I can find is the before and after delete functions.
I am also wondering is there a way to capture when just a row /record is selected , not a column. When I select a row I want to get the ID of the record.
This is driving me nuts so any help would be appreciated.
Question by:Lisad

Expert Comment

ID: 6996212
I haven't got VB Environment here, some time ago I created an app with datagrids and ran into exactly the same problem.
the datagrid is only able to delete a row (record) visually (with mouseclick) NOT with code.
you must set the property Datagrid.AllowDelete=True .
Isn't there a property 'SelectedCel' or something, for the second part of your question.
Since I haven't got VB here I can't check myself.

LVL 43

Accepted Solution

TimCottee earned 400 total points
ID: 6996222
The datagrid really isn't up to this. You can actually delete a record in code but this isn't the point. As I read it you really just want to hide this row from being displayed. Unfortunately the datagrid doesn't do this. If you were to use a flexgrid for example you can set individual row heights and can therefore set it to zero to prevent the row from being displayed. Unfortunately again you cannot use in-cell editing in a flexgrid (though you can simulate this quite effectively). Overall the best option is to look for a commercial grid such as the VS Flexgrid from http://www.componentone.com which has both the in-cell editing features of the datagrid and the flexibility of the flexgrid (the MS Flexgrid is actually a cut down version of this commercial one).
LVL 15

Expert Comment

ID: 6996432
Maybe add one field "RowIsVisible" to your table, or maybe to the recordset to which DataGrid is bound?

This comment is not intended as answer.
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions


Expert Comment

ID: 6998040
    We ran into this problem and a bunch more concerning datagrids. For example, we wanted a row to expand vertically a la Multiline for Textboxes. We wanted some columns to be check boxes, others to be Comboboxes with automatic translation of codes to text. We wanted to be able to configure just specific cells with these capabilities, rather than whole columns. We wanted ... well, we wanted a lot.
     After looking very hard, we finally settled on ComponentOne's VSFlexGrid, an exceptionally powerful and sophisticated grid. We have yet to run into a problem it won't handle.
     For your specific problem, there are two VSFlexGrid solutions:
     (1) You can hide a row by setting the RowHidden property true. If you have, say, 7 rows of grid "fgr", and you want to delete the 4th row, you'd write:
          fgr.RowHidden(4) = True
     That would move rows 5-7 up one row visually. Row 4 would still be in the grid, but visually it's removed; that is to say, if you processed the grid rows sequentially, you'd still process the hidden row 4 as the 4th row of the grid. The only effect is what the user sees.
     (2) You can actually delete the 4th row in the abov e example by issuing this command:
     In this case, the grid row would be completely removed.
     In neither case is the underlying database changed in any way.
     VSFlexGrid costs about $300, but the whole ComponentOne suite of controls only costs about $400, so that's what we bought. We've been using it about six months now.

Expert Comment

ID: 7078686

This question has been locked with a Proposed Answer, and remains open today.

If the Proposed Answer did not serve your needs, please reject it and comment with an update.  If the Proposed Answer helped you, please accept it to grade and close this question.  If you need help splitting points between multiple experts, please comment here with details so we can help you.

EXPERTS ->  Please guide me here in terms of closing recommendations if the Asker does not respond in 4 days.

Thanks to all,
Moondancer - EE Moderator

Expert Comment

ID: 7522867
Dear GebhartBob@devx
I've rejected your proposed answer as Experts Exchange holds an experiment to work without the answer button.

See: <http://www.experts-exchange.com/jsp/communityNews.jsp>
Paragraph: Site Update for Wednesday, November 06, 2002

By this rejection the Asker will be notified by mail and hopefully he will take his responsibility to finalize the question or post an additional comment.
The Asker sees a button beside every post which says "Accept This Comment As Answer" (including rejected answers) -- so if he/she thinks yours is the best, you'll be awarded the points and the grade.

EXPERTS: I will return in seven days to close this question.
Please leave your thoughts and recommendations here


Thanks !

Experts Exchange Moderator
LVL 16

Expert Comment

ID: 7895782
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
- answered by TimCottee
Please leave any comments here within the
next seven days.


Cleanup Volunteer

Expert Comment

ID: 7941745
per recommendation

Community Support Moderator @Experts Exchange

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question