From: Rick Rothstein (MVP - VB) on
>> > How do I get the value when a user double clicks a cell????
>>
>> You can use the TextMatrix method coupled with the MouseRow and MouseCol
>> properties. For example,
>>
>> Private Sub MSFlexGrid1_DblClick()
>> With MSFlexGrid1
>> Debug.Print .TextMatrix(.MouseRow, .MouseCol)
>> End With
>> End Sub
>
> OK however it seems with that code you have to specify the row and col
> i.e.
> MouseRow Mouse col but the user double clicks anywhere on the grid and I
> need
> to get that number????

Maybe you are not familiar with the With/EndWith block construction. Here is
the same code without using that structure...

Debug.Print MSFlexGrid1.TextMatrix(MSFlexGrid1.MouseRow,
MSFlexGrid1.MouseCol)

More than likely, the above line has wrapped on your newsreader... if that
is the case, just remember it is all to be placed on one line in your
program. The thing you should note is that MouseRow and MouseCol are
properties of the grid, not independly created variables... the Grid will
fill in the row and column numbers for the cell that the mouse is over when
the line is executed.

Rick


From: Bob Butler on
"Mitch5713" <mitch(a)nnex.net> wrote in message news:234F2942-3866-4917-
9579-1D7FE306E84D(a)microsoft.com
> That seems to just return an arbitrary value not the value of the row
> and col the user double clicked?????

not for me... start a new project, add an msflexgrid1 to the form and try
this code:

Private Sub Form_Load()
Dim r&, c As Long
With MSFlexGrid1
.Rows = 5
.Cols = 5
.FixedRows = 1
.FixedCols = 0
For r = 0 To .Rows - 1
For c = 0 To .Rows - 1
.TextMatrix(r, c) = r * 100 + c
Next
Next
End With
End Sub

Private Sub MSFlexGrid1_DblClick()
With MSFlexGrid1
Me.Caption = .MouseRow & "," & .MouseCol & _
"=" & .TextMatrix(.MouseRow, .MouseCol)
End With
End Sub


--
Reply to the group so all can participate
VB.Net: "Fool me once..."

From: PC on
when you (double) click on a cell, that cell becomes the active cell
and you can just ask for its contents:

Private Sub MSFlexgrid_DblClick()
MsgBox MSFlexgrid.Text
End Sub


"Mitch5713" <mitch(a)nnex.net> wrote in message news:1DCC63B3-BED8-414B-BAF8-C71E2840D755(a)microsoft.com...
> I have a flexgrid populated by various numerical data. How do I get the value
> when a user double clicks a cell????
>
> Thanks
From: Irfan S. Fazli on
This is adding on to this discussion regarding MSFlexgrid.
MSFlexgrid is actually a read-only control, i.e. user keystrokes are not
directly reflected in the grid.
How do you make it LOOK like a part of an EXCEL sheet?
Here's how I have managed it:
1. Create as many textboxes (can be checkbox or combobox as well)
(invisible at design time) as columns or the columns to be made look like
'read-write'.
2. On User keystrokes, identify the active cell (row-col) (using method
discussed in this thread) set the position (control.top, .left) as
textbox.Top = flxg.CellTop + flxg.CellHeight - (flxg.GridLineWidth * 100)
textbox.Left = flxg.ColPos(5) + 100
textbox.Font.Name = flxg.Font.Name ' this to make it LOOK the same
control
3. Make the corresponding control visible and setfocus to it. (You can also
set the textbox.text = contents of the active cell and allow editing).
4. On pressing ENTER /TAB etc navigation keys (use the textbox.keypreview)
set the cell of the grid to the textbox value, exit the textbox, make it
invisible and setfocus to the flexgrid.

This CAN be achieved without adding the textbox controls, just use
keypreview of flexgrid, identify the cell, and process the keystrokes as the
textbox processes your editing and navigation keystrokes.

--
IRFAN.



"PC" wrote:

> when you (double) click on a cell, that cell becomes the active cell
> and you can just ask for its contents:
>
> Private Sub MSFlexgrid_DblClick()
> MsgBox MSFlexgrid.Text
> End Sub
>
>
> "Mitch5713" <mitch(a)nnex.net> wrote in message news:1DCC63B3-BED8-414B-BAF8-C71E2840D755(a)microsoft.com...
> > I have a flexgrid populated by various numerical data. How do I get the value
> > when a user double clicks a cell????
> >
> > Thanks
From: Jan Hyde on
Mitch5713 <mitch(a)nnex.net>'s wild thoughts were released on
Thu, 17 Aug 2006 09:11:03 -0700 bearing the following fruit:

>OK however it seems with that code you have to specify the row and col i.e.
>MouseRow Mouse col but the user double clicks anywhere on the grid and I need
>to get that number????


?? And you get that number with the MouseRow and MouseCol
properties of the grid? Did you try Rick's example?

J

>"Rick Rothstein (MVP - VB)" wrote:
>
>> >I have a flexgrid populated by various numerical data.
>>
>> If it is in an MSFlexGrid control, it is textual data, not numeric data. If
>> you need to use it as a number after retrieval, you should use one of the
>> Cxxx functions to convert it.
>>
>>
>> > How do I get the value when a user double clicks a cell????
>>
>> You can use the TextMatrix method coupled with the MouseRow and MouseCol
>> properties. For example,
>>
>> Private Sub MSFlexGrid1_DblClick()
>> With MSFlexGrid1
>> Debug.Print .TextMatrix(.MouseRow, .MouseCol)
>> End With
>> End Sub
>>
>>
>> Rick
>>
>>
>>


Jan Hyde (VB MVP)

--
Could you say that a cannibalistic lion might swallow his pride?
(Ken Shurget)