ms flex grid question

saryon
07-24-2002, 11:44 AM
righty-o....going to go on lunch break soon so I'll just toss out my ms flex grid question :) (or if I need to use something else for this, any suggestions welcom)

3 column ms flex grid, first column is pulled in from an array, 2nd is inputted from user and 3rd is calculated from info in the 2nd column and a combo box off to the side. The 1st and 3rd should be locked and I would like every odd row to be a certain color and every even row to be a different color (Easier on the eyes I guess lol). Thanks for the help!!

nemaroller
07-24-2002, 01:04 PM
You have your work cut out for you...
There is no native support for editing values for a flexgrid. You have two options assuming you stick with MS flexgrid and not some third party control:

1) Put a fixed textbox above the flexgrid on the form, that accepts the user input. Its always visible, and you don't have to write extensive code for below, but its also inflexible.

OR (Excel spreadsheet style):
2) Use a textbox to appear over a cell when the user clicks on the cell, which makes it appear as though they are editing that cell, and when they press Enter, the textbox disappears and msflexgrid1.text = text1.text.

To accomplish that:
a) You will have to make a textbox the same size as an individual cell of the flexgrid, so it looks natural, using textbox1.height = msflexgrid1.cellheight and textbox1.width = msflexgrid1.cellwidth. You keep this textbox invisible until:

b) When a cell is clicked and raises the Msflexgrid1_Click() event:

1) position the textbox by setting the textbox.left = msflexgrid.cellleft, and the textbox.top = msflexgrid1.celltop...
2) Make the textbox visible, and set focus by using textbox1.setfocus

3) Use the Textbox1_Keypress(ascii as integer) event to check for ENTER which would be ascii=13... and then make the textbox invisible, set the msflexgrid.text = text1.text. Clear the textbox.




The rest of your requirements are easy, but that 2nd row user input will take a little work at first...

saryon
07-24-2002, 01:37 PM
alright...here's the way I'm thinking of doing it and maybe you can add a bit, becos so far it's greatly appreciated.

What I think I would do would be to have when the cell is clicked, just pop up an input box and pull it from that. So how would I store the information from the input box into the clicked cell?? That's what I'm kinda lost on :
)

Flyguy
07-24-2002, 01:44 PM
In the click event store the returned string using .TextMatrix(.Row, .Col)

saryon
07-24-2002, 02:05 PM
alright...cool...now, can someone walk me through the basic process of putting something in?? because it isn't working for me...here is what I'm using


For x = 0 To UBound(labort)
msf.TextMatrix(x, 0) = labort(x)
Next

msf.additem labort(x)
didn't work either

Flyguy
07-25-2002, 01:47 AM
Just a simple code example how to fill a FlexGrid

Dim lRow As Long, lCol As long

With MSFlexGrid1
.Rows = 10
.Cols = 10
For lRow = 0 To .Rows - 1
For lCol = 0 To .Cols - 1
.TextMatrix(lRow, lCol) = "R" & lRow & "C" & lCol
Next lCol
Next lRow
End With

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum