Results 1 to 15 of 15

Thread: MSHflexgrid leavecell event

  1. #1

    Thread Starter
    Fanatic Member Peekay's Avatar
    Join Date
    Sep 2006
    Location
    Witbank, South Africa
    Posts
    784

    MSHflexgrid leavecell event

    How can I enforce a Leavecell event for the previous cell before the the Entercell event of the next cell is fired, when I move from one cell to another, without using vbCr?

    Thanks
    PK

  2. #2

    Thread Starter
    Fanatic Member Peekay's Avatar
    Join Date
    Sep 2006
    Location
    Witbank, South Africa
    Posts
    784

    Re: MSHflexgrid leavecell event

    Sorry, this problem changed it's name.
    I have a control which has focus and is situated over the flexgrid, so what I really need to do is pick up the lostfocus event of this control.
    The problem is that this control may be any of many which was set like this:

    Code:
    Set EditGrid ='may be any of twenty controls"
    How can I pick up the lostfocus event of such a control?

    Thanks
    PK

  3. #3
    Frenzied Member
    Join Date
    Apr 2012
    Posts
    1,253

    Re: MSHflexgrid leavecell event

    Declare EditGrid as 'WithEvents' and then you will have access to an 'EditGrid_LostFocus' event handler.
    If you don't know where you're going, any road will take you there...

    My VB6 love-children: Vee-Hive and Vee-Launcher

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: MSHflexgrid leavecell event

    I think his problem is that he uses multiple controls as his marquee control for data editing/entry.

    Imagine just a TextBox and a ListBox. I don't think these implement any common interface, which is why they can't be used with a VBControlExtender object reference variable unlike an ActiveX control. Even if they do, it is a different one we have no typelib for.

    The intrinsic controls are sort of a vestige of pre-ActiveX VB. I had the idea that we almost got Unicode-aware and ADO-aware replacement controls based on what became fm20.dll and mswless.ocx but it wasn't going to be ready yet for VB6. Since we never got an actual VB7 here we are.

  5. #5
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: MSHflexgrid leavecell event

    @Peekay, maybe switch to the vbFlexGrid by Krool.
    It can be found in the Codebank

  6. #6
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: MSHflexgrid leavecell event

    @Peekay, maybe switch to the vbFlexGrid by Krool.
    It can be found in the Codebank

  7. #7
    Frenzied Member
    Join Date
    Apr 2012
    Posts
    1,253

    Re: MSHflexgrid leavecell event

    Quote Originally Posted by dilettante View Post
    I think his problem is that he uses multiple controls as his marquee control for data editing/entry.
    Ahhh, I see...

    Still, that being the case, he could simply wrap a class around those different control-types and raise the event from there.
    If you don't know where you're going, any road will take you there...

    My VB6 love-children: Vee-Hive and Vee-Launcher

  8. #8

    Thread Starter
    Fanatic Member Peekay's Avatar
    Join Date
    Sep 2006
    Location
    Witbank, South Africa
    Posts
    784

    Re: MSHflexgrid leavecell event

    Thanks guys. I think I will start off with Colin's event proposal and go down the list until something works.
    PK

  9. #9
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: MSHflexgrid leavecell event

    Quote Originally Posted by ColinE66 View Post
    Still, that being the case, he could simply wrap a class around those different control-types and raise the event from there.
    Well, you don't normally do that because it's a lot of extra work to create and support. You might save most of that by wrapping a UserControl around the controls though, since UserControls are a Class plus control hosting and event binding.

    Considering how infrequently you'd need this I'm not sure it's worth it. Just handle the events from the two or three controls used as marquees just as you would if they were all just left visible in the same position all the time.

    If we assume that a lot of the same work gets done in the LostFocus handler for each of these controls why not just have the event handler routines call a common subroutine passing any arguments necessary? You'll end up doing that anyway in a UserControl or a Class that handles their events.


    This sounds more and more like a Tower of Babel maintenance nightmare where none is needed.


    I went back and read the question again. The "twenty controls" has me laughing now. Why would there be twenty controls??? Normally you just use one control for this, and the only reason for more might be if you needed more than one type of control. For example a TextBox might be used for 19 of your columns but for a 20th column you want a ListBox. That's two controls, not 20.

  10. #10

    Thread Starter
    Fanatic Member Peekay's Avatar
    Join Date
    Sep 2006
    Location
    Witbank, South Africa
    Posts
    784

    Re: MSHflexgrid leavecell event

    dilettante,

    Thanks. I am pondering all the advice seriously.

    Firstly, I am not well acquanted with wrapping all edit controls into one class, and need to learn that from scratch, which I will do if I am convinced that it is the way to go. In fact you helped me last time developing my own user datetime control which I use with advantage.

    Secondly, I use about 20 controls. It is true that I only need about four controls like textbox, combo box, datetimepicker snd so on, but because I do not want to clear one combo box and re-populate it with different data everytime, I use a lot of different combo boxes for each table. I am considering using only four controls after reading your advice.

    Editing with controls on the flexgrid is at the heart of my program, but the problem is catching the event which can lead to an update of the data. it can either be by the control lostfocus event or the flexgrid leavecell event, but when I edit cells which do not need controls, things get a little mixed up.

    PK

  11. #11
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: MSHflexgrid leavecell event

    I don't mean to minimize the effort required.

    This stuff is always a lot of work to get right. Even deciding how to deal with keyboard navigation of the cells takes some planning and effort since requiring users to navigate by mouse-clicking usually isn't acceptable. Does the Tab key move between controls or does it move between grid cells? Ctrl-Tab? Arrow keys? Enter?

    Some controls can be a little bit intractable too. A single-line TextBox will tend to "spring" to an integral height based on its Font setting if you change its width.

    The slicker you try to get the more work you have to do.

  12. #12

    Thread Starter
    Fanatic Member Peekay's Avatar
    Join Date
    Sep 2006
    Location
    Witbank, South Africa
    Posts
    784

    Re: MSHflexgrid leavecell event

    Dilettante,

    You understand well what I am doing. I only have two events presently, the one is pressing enter which is full proof but cumbersome for the user to execute and the other one moving with the mouse to another cell which is problematic if the next cell does not take a control like a yes/no cell or bringing up a selection form. I feel if I can add a reliable editcontrol lost focus event I will have it robust and taped.

    My routines are already very sleek and in this one application alone I have about 1500 of these change cell events for 160 different functions.

    I have to do it this way as I have a user authority level set for every cell and on entering a cell the program decides what type of data edit, if any, that user level may do on that cell data.

    Thank you for always helping me. I appreciate. You might have gathered that programming is not my main career activity - not by a long shot.

    PK
    Last edited by Peekay; Aug 27th, 2019 at 12:52 AM.

  13. #13

    Thread Starter
    Fanatic Member Peekay's Avatar
    Join Date
    Sep 2006
    Location
    Witbank, South Africa
    Posts
    784

    Re: MSHflexgrid leavecell event

    How would I raise an event in my form to simulate a flexgrid_mouseup(..) event in an mshflexgrid control to enter a cell when I have the row and column numbers?

    Thanks
    PK

  14. #14
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: MSHflexgrid leavecell event

    By moving the code which is currently in the FlexGrid_MouseUp() event to a separate subroutine.
    Then calling this subroutine from the original MouseUp event and calling whenever needed from other routines.

    Code:
    ' The ... represents the original function parameters
    
    Private Sub FlexGrid_MouseUp(...)
      pHandleFGMouseUp ...
    End Sub
    
    Private Sub pHandleFGMouseUp(...)
      ' Your original MouseUp event code
    End Sub
    
    Private Sub pSomeOtherRoutine()
      If bWhatEverTriggeredIt Then
        pHandleFGMouseUp ...
      End If
    End Sub
    You can always in code check the current active cell.
    Use the .Col, .Row, .ColSel, .RowSel properties
    To know over which cell the mouse is hovering use the .MouseCol and .MouseRow properties

  15. #15

    Thread Starter
    Fanatic Member Peekay's Avatar
    Join Date
    Sep 2006
    Location
    Witbank, South Africa
    Posts
    784

    Re: MSHflexgrid leavecell event

    Excellent thanks,
    PK

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