Results 1 to 7 of 7

Thread: Controls in a msflexgrid

  1. #1

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Controls in a msflexgrid

    As msflexgrids are not so flexible as the name suggests, I'm using a textbox for data input, so that after hitting return or any other key the proper action is taken (most of the time the textbox must be moved to fit into a neighbouring cell). The inputbox has a light blue background so as to simulate highlighting of the cell it is over.

    Also in one of the flexgrid rows is an array of comboboxes, in another row an array of checkboxes and finally, a row has an array of (2 per cell) radio buttons. So if the textbox is in the cell just one above one of these and the down arrow key is hit, it must be made invisible and the control that receives the focus must be highlighted. When this control loses the focus, its backcolor must be set back to default. However, in the case of radio buttons, the control width is so small (to allow 2 of them to fit into the cell) that all that can be done is highlighting the cell itself.
    I want to be able to run over all the cells and controls using just the keyboard, but allowing mouse clicks of course.

    The whole thing is rather messy and for every problem I fix a new one appears, it's like continuously patching an old garment.

    My question is: has anyone worked on something similar? Is there any "general" solution to this scenario? What approach would you guys advise? What I need is the general outlines.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  2. #2

  3. #3

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: Controls in a msflexgrid

    Quote Originally Posted by RhinoBull
    You don't have to use Textbox for editing cells - link in my signature will "take" to a thread with multiple flexgrid tips and tricks.

    Also, cell style usually goes by the column - not byt the row.
    Hi RB, interesting tips, indeed.

    Now, the main reason I use a textbox is I want to have the possibility to select the text, as the textbox has the SelStart and SelLength properties. Can you do that somehow with the flexgrid alone? If I want to change a cell's contents I hate having to delete the characters one by one -to be sure I can use the mouse e.g. clear the cell by right clicking, but I want to be able to do it with the keyboard as well...
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  4. #4
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Controls in a msflexgrid

    in another row an array of checkboxes and finally, a row has an array of (2 per cell) radio buttons.
    Also, rather than using controls, you can easily simulate CheckBoxes and Option buttons using symbolic fonts.

    VB Code:
    1. Private Sub Form_Load()
    2.     With Me.MSFlexGrid1
    3.         .Cols = 3
    4.         .Rows = 20
    5.         .ColWidth(0) = 300
    6.         .ColWidth(1) = 1200
    7.         .ColWidth(2) = 400
    8.        
    9.         .FillStyle = flexFillRepeat
    10.         .Row = 1
    11.         .Col = 2
    12.         .RowSel = .Rows - 1
    13.         .CellFontName = "Wingdings"
    14.         .CellFontSize = 16
    15.         .ColAlignment(2) = flexAlignCenterCenter
    16.         .Text = "q"
    17.         .FillStyle = flexFillSingle
    18.         .Row = 1
    19.         .Col = 1
    20.        
    21.     End With
    22. End Sub
    23.  
    24.  
    25. Private Sub MSFlexGrid1_Click()
    26.     With MSFlexGrid1
    27.         If .MouseCol = 2 Then
    28.             If .TextMatrix(.Row, 2) = "q" Then
    29.                 .TextMatrix(.Row, 2) = "þ"
    30.             Else
    31.                 .TextMatrix(.Row, 2) = "q"
    32.             End If
    33.         End If
    34.     End With
    35. End Sub

  5. #5

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: Controls in a msflexgrid

    I'm wondering if it's worth using this control rather than the msflexgrid.

    Looks like there's a large amount of information to read before you can get going, so I'd like to hear from anyone who may have used it.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  6. #6

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: Controls in a msflexgrid

    Quote Originally Posted by brucevde
    Also, rather than using controls, you can easily simulate CheckBoxes and Option buttons using symbolic fonts.
    [/Highlight]
    If I have 2 radio buttons in the same cell, how do I go about simulating the click events? Do I have to check the mouse coordinates in the flexgrid's MouseMove event? May be a bit cumbersome, unless you assure me it really isn't...
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  7. #7

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: Controls in a msflexgrid

    To be continued in this new thread.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width