• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 134
  • Last Modified:

Cannot get mshflexgrid to reconize events

I have done this many times in the past:eg
in fact a lot of the code is copied from past projects
Make the mshflexgrd editable by placing a textbox over the selected cell
but for some reason I can not get the grid to recognize events:

grid2Column_LeaveCell
or
GridMain_EnterCell
The grid 2nd column(1)
grid2Column
The textbox to edit cells:(txtEdit)
What could be causing the mshgrid to not fire events ?  Editt-griid.jpgGet-Bids-08-09-14.zip
0
isnoend2001
Asked:
isnoend2001
  • 13
  • 13
1 Solution
 
Martin LissRetired ProgrammerCommented:
The event is probably being absorbed by the textbox, if that's the cell you are clicking.
0
 
isnoend2001Author Commented:
Yes
What i don't understand is why this has never happened before
0
 
Martin LissRetired ProgrammerCommented:
So you want the underlying grid to respond to the click? If so, why, and maybe I could be of more help if you uploaded your project.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
isnoend2001Author Commented:
Thanks Martin Liss
I thought i attached the project. If not i will again
0
 
Martin LissRetired ProgrammerCommented:
You did. I just overlooked it and I'll download it now.
0
 
isnoend2001Author Commented:
good, thanks
0
 
Martin LissRetired ProgrammerCommented:
What are the steps necessary to reproduce the problem?
0
 
Martin LissRetired ProgrammerCommented:
Also I don't know what event in the grid that you want to have happen when the textbox is clicked, but your floating textbox is not behaving properly in that it's carrying over values from the previous cell. I've attached a demo floating textbox project and maybe if you compare the two you can see what you aren't doing correctly.
Project1.zip
0
 
isnoend2001Author Commented:
If typed into the last column the typed text will be entered into the selected cell and the textbox cleared
When entering a new cell the contents of the grid are entered into the textbox and can be edited or deleted.
i have used this method on many grids in the past, never ran into this problem before
0
 
Martin LissRetired ProgrammerCommented:
OK but as I said your floating textbox is not working properly and I think if you fix that then the other problem will go away.
0
 
isnoend2001Author Commented:
I will check your zip.
I know the action needs tweaking.But
Cannot tweak until the grid recognizes events eg
grid2Column_LeaveCell
or
GridMain_EnterCell
0
 
Martin LissRetired ProgrammerCommented:
My demo does does that so again I suggest that you need to fix your textbox code.
0
 
isnoend2001Author Commented:
Re:
I suggest that you need to fix your textbox code.
what is the the problem ?
I notice you code puts the typed text into the cell, but if the cell contains text it is not put into the textbox.
0
 
Martin LissRetired ProgrammerCommented:
In my code add lines 27 to 29.
Sub MSFlexGridEdit(MSFlexGrid As Control, Edt As Control, KeyAscii As Integer)

    ' This only happens for the 1st character entered.
    ' The other characters are typed into txtEdit.
    
    ' Use the character that was typed.
    Select Case KeyAscii

    ' A space means edit the current text.
    Case 0 To 32
        Edt = MSFlexGrid
        Edt.SelStart = 1000

    ' Anything else means replace the current text.
    Case Else
        Edt = Chr(KeyAscii)
        Edt.SelStart = 1
    End Select

    ' Show Edt at the right place.
    Edt.Move grdFloat.Left + MSFlexGrid.CellLeft, MSFlexGrid.CellTop + MSFlexGrid.Top, _
        MSFlexGrid.CellWidth, MSFlexGrid.CellHeight
     
    Edt.Visible = True

    If Edt.Text = "" Then
        Edt.Text = MSFlexGrid.Text
    End If

    ' And let it work.
    Edt.SetFocus
End Sub

Open in new window

0
 
isnoend2001Author Commented:
Thanks Martin Liss seems you want to change the way my code works This could be a good thing with a little tweaking. Eg; color cell or textbox upon entering cell and put cell text into textbox,
This way a user can tell the cell can be typed.
I still do not know why these events don't fire:
grid2Column_LeaveCell
or
GridMain_EnterCell
0
 
Martin LissRetired ProgrammerCommented:
Most likely they don't fire because the text box is in the way. I'm away from home but if you can wait until morning I'll have your project fixed up.
0
 
isnoend2001Author Commented:
Thanks MartinLiss got plenty to do other than that. I can wait
0
 
Martin LissRetired ProgrammerCommented:
Try this. All the changes I made are marked with 'new

Also just a suggestion but when you zip up a project don't include the vbw file since that file is only a record of how your VB6 workspace is set up (window sizes and positions, etc) and if it's not included the recipients workspace set up will be used.
Q-28494264.zip
0
 
isnoend2001Author Commented:
Thanks MartinLiss that sure fixed my problem
0
 
isnoend2001Author Commented:
Hi Martin liss
I noticed that when grid is clicked the color of the heading on Col1 was lost.
I fixed it like this:
 on form load
grid2Column.Row = 1 'added this to stop loosing backcolor of heading(light yellow)
  grid2Column.Col = 0
would this be correct ?
0
 
isnoend2001Author Commented:
Hi Martin Liss I looked at a past project i wrote a couple yrs ago
It contained 19 editable mshflexgrids on many forms. I never had the problem i posted here.
You have provided a fix for this problem, but i remain in the dark as to why, suddenly i had this problem.
Before i posted i tried everything to overcome this issue.
BTW
when i post questions I always hope you are the one who answers
Glad you are here
0
 
Martin LissRetired ProgrammerCommented:
You're welcome and that's nice to hear. I'm not at home (again) but when I get a chance I'll try to figure out why your posted project doesn't work.
0
 
Martin LissRetired ProgrammerCommented:
I don't know how your original project worked before but the problem was that on txtEdit LostFocus the contents of txtEdit were being put in the new cell rather than the previous cell where txtEdit used to be. Here's a version with a few small changes.
Project1.zip
0
 
isnoend2001Author Commented:
Thanks MartinLiss
After looking at your changes I am bewildered as to why the other grids work as good as they do, but they do. I copied-pasted the code from one, must have missed something in the process
0
 
Martin LissRetired ProgrammerCommented:
If you can't figure out why, post one of the projects that works.
0
 
isnoend2001Author Commented:
Thanks MartinLiss, but the project is huge with tons of purchased ocx's
Those work correctly and the one you have helped me with works so i am moving on.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 13
  • 13
Tackle projects and never again get stuck behind a technical roadblock.
Join Now