 |
panik! Level: Big Cheese
 Registered: 12-02-2005 Posts: 19
|
beginer question
Okay, I'm just starting out with VB. I've read some beginer's books. I've worked with TurboPascal, Fortran and BASIC. Anyway, I am working on a VBA (for Inventor) program and am wanting to display information as a grid (like a spreadsheet). I would like to be able to sort and change data fields. I have found the MSFlexGrid and assume that is the right tool to use. Is there a better way to do this? And, I can display these properties using the Debug.Print statement, would I just replace this statement with the MSFlexGrig row & col number equal to the property, to display it in the grid?
Thanks.
|
|
12-02-2005 at 08:27 PM |
|
|
Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1681
|
Re: beginer question
msflexgrid is read-only grid control, so if oyu dont need to allow user to change data through it, then it will serve your purpose. I dont know what you mean by displaying properties, but if you want to assing value to cell use textmatrix property
| msflexgrid1.textmatrix(row,col)="some value" |
____________________________
If you find the answer helpful, please mark this topic as solved.
|
|
13-02-2005 at 02:25 AM |
|
|
panik! Level: Big Cheese
 Registered: 12-02-2005 Posts: 19
|
Re: beginer question
Thanks, That is what I was looking for. So then, if I did need to change the values in the cells, is there a better tool to use? Or would I be better off using the FlexGrid and use a different method to do the editing?
Thanks!
|
|
13-02-2005 at 12:48 PM |
|
|
Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1681
|
Re: beginer question
Every MS grid has its advantages and disadvantages. The disadvantage of flexgrid is that it is read-only. You can simulate editing, by putting textbox over the cell that user wants to edit (textbox will have same width and height as cell does), and after user preses enter, you can pass textbox value to flexgrid and then set texbox.visible=false. I dont use MS grids, cause there are much better products that do cost, but they are worth of the price.
____________________________
If you find the answer helpful, please mark this topic as solved.
|
|
13-02-2005 at 07:22 PM |
|
|
pavane Level: VB Lord
 Registered: 26-04-2004 Posts: 179
|
Re: beginer question
The VB manual (online as well as printed) shows how to place a texbox onto a grid, and also how to update the flexgrid from the textbox. It's a bit of a chore though, keeping all the scrolling etc in line with the grid. And I still can't get the flexgrid row heights to match the text box, I have to adjust the textbox to suit the grid. Something to do with the font, maybe.
So yes, the flexgrid isn't ideal.
|
|
14-02-2005 at 08:35 AM |
|
|
panik! Level: Big Cheese
 Registered: 12-02-2005 Posts: 19
|
Re: beginer question
Okay, I will look into other grids. This (FlexGrid) will work for now.
I was able to put all of my data into the grid. (Thanks for the help) Now I am working on formatting the data, which I can do. But it seems my method is too much "brute force and ignorance". The only way I found to change the format of a cell while writing text to it is to set the individual row and collumn, set the formatting then write the text. It seems like there would be an eaiser way. I am using these 4 statements everytime I want to write a "formatted" cell. I have found how to set the grid globally, but that is not what I want.
UserForm1.MSFlexGrid1.Row = 0
UserForm1.MSFlexGrid1.Col = 0
UserForm1.MSFlexGrid1.CellAlignment = _ flexAlignCenterCenter
UserForm1.MSFlexGrid1.TextMatrix(0, 0) = "Item"
Is there a way to combine these statements, or a more elegant way to do this?
Thanks again!
|
|
14-02-2005 at 12:38 PM |
|
|
|
|
 |
 |