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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rightclick event in Grid specific row/column 1

Status
Not open for further replies.

Ed Andres

IS-IT--Management
Mar 27, 2001
142
US
I am trying to create a rightclick event on the textbox of the first column of a grid. I have the grid already on the form and when the user enters a value in a textbox and presses enter, I use the following code to get the data and then add it to the grid.

If I add the right click event to the textbox of the grid it seeems to work only for the first data set. Every other try, without unloading the form does not have a rightclick event. Seems like I need to add the rightclick event when I setup the grid but don't know how.

*** Get Data
SQLSelect = "SELECT SerialNumber, "+;
"CalDate, "+;
"CalibrationGas, "+;
"TechName, "+;
"ID "+;
"FROM LeakSTD "+;
"WHERE SONumber = " + ALLTRIM(thisform.txtSono.Value) + " "+;
"ORDER BY SerialNumber"

= SQLEXEC(lnConn, SQLSelect, 'LS_data')

*** Setup Grid
WITH thisform.grid1
.ColumnCount = 5
.DeleteMark = .F.
.RecordSource = 'LS_Data'
.width = 550
.Column1.ControlSource = 'LS_Data.SerialNumber'
.Column1.Width = 85
.Column1.Name = "Column1"
.Column1.Header1.caption = "Serial #"
.Column2.ControlSource = 'LS_Data.Model'
.Column2.Width = 200
.Column2.Name = "Column2"
.Column2.Header1.caption = "Model"
.Column3.ControlSource = 'LS_Data.CalDate'
.Column3.Width = 85
.Column3.Name = "Column3"
.Column3.Header1.caption = "Cal Date"
.Column4.ControlSource = 'LS_Data.CalibrationGas'
.Column4.Width = 85
.Column4.Name = "Column4"
.Column4.Header1.caption = "Cal Gas"
.Column5.ControlSource = 'LS_Data.TechName'
.Column5.Width = 85
.Column5.Name = "Column5"
.Column5.Header1.caption = "Tech"
.scrollbars = 2
.Visible = .T.
ENDWITH


Ed
 
Ed,

The problem is that, each time you do the SELECT, you are temporarily deleting the cursor (LS_Data) just before you recreate it. This has the effect of deleting all the columns in the grid, along with their method code.

A quick workaround is to detach the cursor from the grid just before you do the SELECT. In other words, do Thisform.Grid1.RecordSource = "". Then proceed as before.

For more on this, see "Controlling grid data dynamically", at
Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike,
Thanks for the FAST response.
It worked great.

I will check out your posted link.

Thanks again,

Ed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top