Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MSHFLEXGRID! Did the user really pick something?

Status
Not open for further replies.

thornmastr

Programmer
Feb 2, 2002
1,337
US
I am almost certain this question has been answered and I am simply misquoting my search string. I have a MSHFlexgrid on a form. The user can select a row to delete from the underlying table which works just fine provided that the user has actually selected a row. However, if the user selects nothing and clicks the delete button, it deletes the last row.

My current way around this is to pop a message box asking the user if they really want this row (MSHFlexGrid1.Text) to be deleted. Pressing YES fires a delete query for that row. Pressing NO ignores the delete request.
How do I tell that a row really has been selected or, more truthfully, how do I tell that no row has been selected.

Thank you for your help.


Robert Berman
Data Base consultant
Vulcan Software Services
thornmastr@earthlink.net
 
I've resorted to changing the back color and forecolor of the "selected" row(s) to white on red and then asked if the selected row(s) should be deleted. If the answer is yes, the "red" row(s) are deleted. If it's not what they really want deleted.... not my problem anymore.

Mark

"You guys pair up in groups of three, then line up in a circle."
- Bill Peterson, a Florida State football coach
 
Mark,

Thank you for the suggestion.

What I was really hoping for was some property I was missing, something along the line of:

Mshflexgrid1.somethingwaspicked

Obviously, no such luck.


Robert Berman
Data Base consultant
Vulcan Software Services
thornmastr@earthlink.net
 
Why can't you use a variable, ie RW=MSFlexgrid.Row in the grid click property. You could clear RW after deleting the row, and then use an empty RW to stop unwanted delition of wrong row, or set the parameters against RW to stop wrong row comming out?
 

What about the RowSel property, or setting a variable in the MSHFlexGrid1_SelChange event to tell when a (different) row has been selected?
 
I think the question is whether the user "selected" a row rather than if there is a row selected in the flexgrid. In either case, some input from the user is required in order to verify that the selected row really is a row the user wants to delete.

One possibility is to remove the Delete button and use a popup menu on the flexgrid mousedown/right-click and offer a delete option on the highlighted row. That forces the user to deliberately initiate the delete action and maybe then you can forgo the ugly msgbox verification action.

Mark

"You guys pair up in groups of three, then line up in a circle."
- Bill Peterson, a Florida State football coach
 
CCLINT and Mark,

Please be advised my lack of communication was not because of rudeness or inconsideration. Rather, I was trying both of your ideas.

Mark, I think I very clearly stated what I was “hoping for” when I asked was there not some property, such as a “somethingwaspicked” property. Unfortunately, no such luck. I truly thought CCLINT’s idea of using rowsel might well be the answer and indeed it is the answer once the rowsel property of the flexgrid is set to 0 when it is first filled. That way, once a row is selected the rowsel propery will reflect the chosen row.

It would have been nice if the rowsel property had not been set to the first row or the last row when the grid is first filled.

I think for elegance, Mark’s method is excellent and I may well go to his method utilizing the right mouse button at some point in the future.

Again, I thank all of you who have posted for both your suggestions and your time.


Robert Berman
Data Base consultant
Vulcan Software Services
thornmastr@earthlink.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top