Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating MSHFLEXGRID - Urgent!!!! 1

Status
Not open for further replies.

gazal

Programmer
Apr 30, 2003
212
0
0
OM
hi friends

I have created a Hierarchical FlexGrid (MSHFlexGrid) using DataEnvironment.
It displays the Data Properly, but i got problems in updating the records.
As we all know that MSHFLEXGRID is a read only Grid, and we have to use
Text Box to make it editable, i have managed that too, but dont know
how to update the underlying RecordSet coz its coming from DataEnvironment.
Please note i am using VB 6 and Access 2000 on windows 98.

One more small thing, in my Parent and Child query the table is same,
if u guys know i have used Equi Join, So when my data is displyed in the Grid
the Joining Column Appears 3 Times, 1 - For the First Commad or Query,
2 - As its the Joining Column, 3 - As its in the Second command or Child Query.

I tried hiding two of them using MSHFLEXGRID1.Colwidth(0,1) = 0, it does
not hide the specified column but messess up the grid. So how do i prevent it.

Thanks in advance

Gazal
 
I use the floating textbox often but my underlying recordset is done differently. I don't bind my grid. You lose some control and can end up with problems with complicated queries, as you have.

Instead I take an ADO rescordset and place the data into a UDT array. Then manually feed the data into the grid for display purposes. This way I can keep track of all fields and display only the ones I want. The UDT is just a way to avoid and clarify a double subscripted array. The arrray elements correspond to the grid row so that if I know which row I am on then I know which element of the array I need to work with.

When the data in the grid is updated I update the array as required. Now I can also do any data manipulation on the array and control the number of calls to the database.

This does require a bit more coding but it is not any more complicated than creating the floating text box.

Thanks and Good Luck!

zemp
 
thanks zemp for ur response

but can u provide me with a samll example how do u handle it with arrays.

regards

gazal
 
Post your email a I can send you a small test project.

Thanks and Good Luck!

zemp
 
hi here is my id

smarif1975@yahoo.com

thanks zemp

 
Hi Zemp,

Can u post me the code also ( mursand@yahoo.com ). I would like to see how u r doing this in array.

Thanks...

Muraliambt.
 
Sorry I don't have it any more. However take a look at faq222-3262 and search this for 'floating textbox' in this forum. You should find several good examples.

When you are stuck post your specific problem with your code and we will have a look.

zemp
 
zemp,

Have you managed to get the tab key to move between cells in the grid? I've trapped the relevant (tedious and illogical) events to pick up cursor movements inside my text box which is placed over the relevant cell, but the Key up/down/press events don't fire on either the text box, grid or form when the tab key is pressed. For this reason I'm currently trying to get the DBGrid to work in a non-bound way.
 
Yes I have. The main issue is that in order to trap the tab key you have to set the forms .KeyPreview property to True and Set all the controls .TabStop property to False. Then I use the floating text boxes .keydown event top trap the tab key and manually move the focus to the next cell or control (if I am on the last cell). Also the forms .keypreview and the all controls .tabstop need to be reversed when you leave the grid (Usually in another controls .gotfocus event). The exception are the controls just before and right after the grid in the forms tab order.

Basically like this
1. Set .keypreview and .tabstop in .gotfocus of grid, floating text, control before and control after (tab order).
2. Trap for tab key and move manually to next cell or next control (or previous). Usually trap in the Keydown event.
3. When you hit any other control the reset the .keypreview and .tabstop properties.

Here is an example of the Tab key case in a keydown event
Code:
      Case vbKeyTab
         If Shift = 1 Then
            If msfgCR.Col > 0 Then
               msfgCR.Col = msfgCR.Col - 1
            Else
               If msfgCR.Row > 1 Then
                  msfgCR.Row = msfgCR.Row - 1
                  msfgCR.Col = msfgCR.Cols - 1
               Else
                  txtReceiptNum.SetFocus 'Previous control
               End If
            End If
         Else
            If msfgCR.Col < msfgCR.Cols - 1 Then
               msfgCR.Col = msfgCR.Col + 1
            Else
               If msfgCR.Row < g_intRowCounter Then
                  msfgCR.Row = msfgCR.Row + 1
                  msfgCR.Col = 0
               Else
                  pzeFloat.Visible = False
                  cmdSave.SetFocus 'next control
               End If
            End If
         End If

Here is an example of the gotfocus event of the grid
Code:
Private Sub msfgCR_GotFocus()
   Set_TabStop False 'sub to set tab stop of all controls.
   frmCR.KeyPreview = True
End Sub

Example of the gotfocus on another control to reset the properties.
Code:
Private Sub txtAmount_GotFocus()
   Check_KeyPreview 'sub used by all controls.
End Sub

Private Sub Check_KeyPreview()
'// Check to make sure the form is ready for the tab key.
   If frmCR.KeyPreview = True Then
      msfgCR.Row = 0
      Set_TabStop True
      frmCR.KeyPreview = False
   End If
End Sub




zemp
 
zemp,

Thanks a bunch. This worked a treat and you saved me from myself again. Have a star!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top