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

Can't get double-click to work in Grid 2

Status
Not open for further replies.

TonyScarpelli

Programmer
Jan 23, 2003
361
US
I'm trying to double-click on a row in a grid, but for some reason the event doesn't want to fire. I've tried setting a break on every object from the grid object down, and the only one I can get to work is on the text1 object.

I want to double-click anywhere in the row and get one of the fields displayed.

Anyone have an idea for this?

Thanks.
 
TonyScarpelli

Use the double-click event of the individual textboxes of each columns.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Tony,

Are you trapping the textbox's double-click or the grid's?

The grid's double-click will only fire if you double-click in an area of the grid not occupied by data, that is, below the last row or to the right of the last column.

The text box's double-click will fire when you click in the textbox.

Mike


Mike Lewis
Edinburgh, Scotland
 
Hi Tony,

Suggest, that in all the individual text boxes DoubleClick event, add the code..
This.Parent.Parent.DblClick()

Then put your code.. in the DblClick event of the grid. It is easier to control the code in one place. :)

ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com

 
These are not really the best solutions, are they?

If I have a lot of fields displayed in a grid, that means I have to put the same code in each text box in the row, if I have 20 fields, that's 20 times I have to add the same code to the text boxes, and that doesn't seem to me to be how OOP should work, especially with the new grids.

Isn't there a way to trigger a double-click off the entire row?

Thanks.
 
Tony

, and that doesn't seem to me to be how OOP should work, especially with the new grids.

Not that isn't, the correct way would be to create a textbox class and put the code once in that class and replace all the default textboxes with this new textbox class. Don't confuse the grid's double-click event with the "row's" double-click event, the row is composed of 100 columns, then you have to deal with 100 textboxes.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Thanks, Mike, I knew I'd have to deal with subclassing someday, I guess now's the time. <g>

What I'm actually trying to do is to create a generic picklist/gridsearch form that I can use from any of my applications. I've had a standard one in FP2.6 forever, but it uses jkey. Jkey for FP6/7 now is a costly proposition.

I just want to pass a form a table, the fields, and what field to return, and it would do all the formatting.

I made a nice one that works the way I want, but I had to put the table and fields into the form and used the double-click in each text box. A sloppy way to do it. I'll just have to see what I can do with your idea.

CU
 
Tony

Here is an example (by code) how to replace textboxes in a grid with one textbox class with a double-click event. Copy the following in a program and run it.
Code:
Public oForm
oForm = Createobject(&quot;form1&quot;)
oForm.AddObject(&quot;myGrid&quot;,&quot;myGrid&quot;)
oForm.myGrid.column1.addobject(&quot;text2&quot;,&quot;text2&quot;)
oForm.myGrid.column2.addobject(&quot;text2&quot;,&quot;text2&quot;)
oForm.myGrid.column1.currentcontrol=&quot;text2&quot;
oForm.myGrid.column2.currentcontrol=&quot;text2&quot;
oForm.Show()
Define Class form1 As Form
	Procedure  Load
	Create Cursor myCursor (Name c(20),address c(20))
	Insert Into myCursor (Name, address) Values (&quot;Mike&quot;,&quot;123&quot;)
	Insert Into myCursor (Name, address) Values (&quot;Paul&quot;,&quot;321&quot;)
	Insert Into myCursor (Name, address) Values (&quot;John&quot;,&quot;345&quot;)
	Insert Into myCursor (Name, address) Values (&quot;Ringo&quot;,&quot;567&quot;)
	Insert Into myCursor (Name, address) Values (&quot;Georges&quot;,&quot;987&quot;)
	Go Top
Endproc
Enddefine
Define Class myGrid As Grid
	ColumnCount = 2
	Visible = .T.
Enddefine
Define Class Text2 As TextBox
	Visible = .T.
	Procedure DblClick
	Messagebox(Transform(This.Value))
Endproc
Enddefine


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Tony,

Just a thought ... you might find it easier to use a listbox rather than a grid as the basis of your picklist.

The listbox is altogether simpler, and doesn' have the problem of having to sub-class its componenets. The main disadvantage is that it is limited in the number of entries it can efficiently handle - a few hundred at the most.

Mike


Mike Lewis
Edinburgh, Scotland
 
Thanks very much for the code, Mike Gagnon, I'll try it out. You saved me a bunch of time.

And Mike Lewis, I considered the ListBox, but I have tables that have thousands of records, and there were some other problems I ran into with the ListBox.

CU

Tony Scarpelli
Clinical Engineering Dept.
Maine Medical Center
Portland, Maine 04102
 
Tony,
Using VFP 8.0 and bindevents I was able to grab the dblclick of everything in the grid using the following code in the Init of the Grid.

*!* Init of Grid
DoDefault()
*!*I have a whole resize and menu batch of stuff that I do *!* with every object.
For Each loColumn in This.Columns
For Each loObject in loColumn.Objects
If loObject.Baseclass != 'Header'
BindEvents(loObject,'DoubleClick',;
This,'DoubleClick')
endif
endfor
Endfor

I hope this works for you, BTW VFP 8.0 is worth the upgrade price!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top