I have a list of blocks and have 12 sizes with 12 prices for each block, so I built an array (10,12,12). Now I want the user to be able to edit the information to change prices and/or quantities.
Do I want to use a Flexgrid? If so, how do I load it into my project? I'm kind of stumped right now.
I want to load headings, and then load the data, and have the user edit, which then saves the new data.
I am using a text file, and have the code finished. My program uses the names from this text file, and loads them into a listbox.
Last edited by dglienna; Sep 8th, 2004 at 03:26 PM.
Not sure I understand what the 10 is in the first array spot...
But why not use FLEXGRIDS - you can have 10 of them (hide them behind each other). Use radio buttons to make each one show (still don't know why you have 10 - what that means)...
FLEXGRIDS cannot actually be editted, but it's pretty easy to float a TEXTBOX onto the CELL that is clicked and let the user do entry into it...
I have a new form, do I just do everything in the form load event?
I think that I have the syntax in my Components book.
Is there a sample in Codebank that uses this?
Is there a difference between MSFlexgrid and MSHFlexgrid?
The book doesn't have any AddItem for MSFlexgrid, only the Hierarchical one, which leaves me a bit confused.
I am looking forward to mastering this one...
right now, struggling with where to place sample code.
time out for food!
Last edited by dglienna; Sep 3rd, 2004 at 05:32 PM.
thanks. i was looking for an example of loading an array into the grid, and then editing values before re-saving them for the rest of the program to use.
Not sure how far you have gotten, or the route you are taking...
The flex grid exposes a "string array" that represents each cell.
.TEXTMATRIX(.ROW,.COL) is the property.
You can both set and retrieve values from this array.
This is the "grid cells" that are displayed to the user.
There are add methods - you can add new rows by building a string, each "column" of data separated by a TAB characters, and add that row instantly like that.
Or increase the .ROWS value by one and fill the new row manually (using .TEXTMATRIX(r,c) array)
You can have .FIXEDROWS and .FIXEDCOLS for heading or "left side" fixed rows and columns.
And you can refer to the GRID in all forms in you project, by simply using FORM1.FLEXGRID1.TEXTMATRIX(R,C).
Thanks. If I format the items as currency, will it cause problems to edit it this way, and to place the items back into the array?
I was going to copy them all after editing all of them, but now I am thinking that I can write each one as I edit it.
I just wonder if I should format each one to two decimal places so that it looks right.
i tried textmatrix(1,1)=format(somevalue , #.##)
but it doesn't work. any ideas why?
Last edited by dglienna; Sep 5th, 2004 at 04:11 PM.
I have 210 items in my flexgrid. Now to go about editing them.
I've decided to write the info back at form unload so that the other module gets the new information.
It woud look better formatted, but it *really* isn't necessary.
It shows 4 dollars as 4 and 3.30 as 3.3. Irritating, but liveable.
Comma seperators would be nice for 2333 also.
Originally posted by dglienna Thanks. If I format the items as currency, will it cause problems to edit it this way, and to place the items back into the array?
I was going to copy them all after editing all of them, but now I am thinking that I can write each one as I edit it.
I just wonder if I should format each one to two decimal places so that it looks right.
i tried textmatrix(1,1)=format(somevalue , #.##)
but it doesn't work. any ideas why?
Originally posted by dglienna Comma seperators would be nice for 2333 also.
We have our own home-grown "dollar formatting functions" - actually we prefer to do all our validation and formatting in a single function. It translates from STORED to INPUT to DISPLAY format - based on parameters you set. We use this function throughout all out code for solid-consistency.
If we pass it a US phone number, it verifies that it's 7 or 10 digits and numeric - then if the output format is "DISPLAY" then we put the "()-" edit mask into it.
We only use comma-separators for reports - they are hard to deal with in updates to a database, as they are "invalid" numeric characters.
szlammy - care to share one of them? i can imagine a few ways to do this, but want the best/easiest.
ps - it worked great, but I changed it to #0.00 so that there is always something there, and #,##0 for the quantity.
I couldn't manage to center the row headings, but used "* Qty" which seems to be working.
Last edited by dglienna; Sep 6th, 2004 at 01:40 AM.
When you have a column you want centered, when you're building the headings with the .FORMATSTRING property, put a "^" character as the first character of the heading for that column.
Not at work today - so I can't give you a function for formatting...
thanks. I'll try to implement that later.
I am filling up the form, and would like to be able to edit a cell, and have the same number input into other cells. This way, a user could input a new price, and not have to re-enter it for successive prices (that are the same)
I was going to print the current price, and the last thing typed for the new price. I see this as a way to do it.
szlammy - i can't inplement this. what is f.flxinput? I tried using flxinput as the name of my grid, except that I get the wrong number of arguments when trying to move with flxinput(y)
I have a textbox named txtinput and changed my sub to support the new name.
f is my form (passed as an argument to a SUB in the BASMAIN) and flxinput(y) is the flexgrid. It got a (y) trailing it because it's a control array of many flex grids on a form.
Just change "f.flxinput(y)" to whatever your grid is called.
Private Sub flxinput_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
txtInput.Appearance = 0
txtInput.Tag = Str$(lngFII)
txtInput.Move flxinput.CellLeft + flxinput.Left _
, flxinput.CellTop + flxinput.Top _
, flxinput.CellWidth _
, flxinput.CellHeight
txtInput.Visible = True
txtInput.Enabled = True
txtInput.ZOrder 0
txtInput.MaxLength = flxinput.ColData(flxinput.Col) '
txtInput.Text = flxinput.TextMatrix(flxinput.Row, flxinput.Col)
' txtInput.ToolTipText = "Current Entry Field For the Grid"
' '(" & CStr(f.flxInput(y).Row) & "," & CStr(f.flxInput(y).Col) & ")"
End Sub
OK, when I click on a cell, the textbox doesn't show, and it doesn't allow editing. the textbox disappears from the top of the form, though, so I know that something is working. Its just not the way that I want it. the selected cell is highlighted, though.
i moved it down 50, and saw that the old cell is covered by the textbox, but it doesn't allow editing. if i change the value it goes right back to the old value. i'd like it to wait for the enter key, or else to tab out of the field.
Last edited by dglienna; Sep 8th, 2004 at 03:01 PM.
The idea is that you are covering the CELL with the textbox - which is exactly the same size. Then set the focus to the textbox - where the editing of the TEXTBOX looks like you are editing the cell.
Then on the key events of the textbox, you hide the TEXTBOX and put the contents of it back in the cell.