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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

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.
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

770 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