Page 33 of 33 FirstFirst ... 2330313233
Results 1,281 to 1,291 of 1291

Thread: VBFlexGrid Control (Replacement of the MSFlexGrid control)

  1. #1281
    Hyperactive Member
    Join Date
    May 2018
    Location
    Russia
    Posts
    304

    Arrow Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Calcu View Post
    It's possible to autoadjust the width of the column "before" selecting anyhing ?
    Yes, you may use the ColWidth property and the TextWidth function in the ComboBeforeDropDown or ComboCloseUp events.



    Edited:
    The code below is edited in accordance with the post #1283 by Krool.

    Code:
    Const COL_COMBO = 1
    Private nOldColWidth As Long, bColWidthIsChanged As Boolean
    
    Private Sub Command3_Click()
       With VBFlexGrid1
          .ColComboCue(COL_COMBO) = FlexComboCueDropDown
          .ColComboMode(COL_COMBO) = FlexComboModeDropDown
          .ColComboItems(COL_COMBO) = "Arnold|Bob|Charlie|David"
       End With
    End Sub
    
    Private Sub VBFlexGrid1_ComboBeforeDropDown( _
             ByVal Reason As VBFLXGRD17.FlexComboDropDownReasonConstants, _
                   Cancel As Boolean)
    
       Dim nTextWidth  As Long, nNewTextWidth As Long
       Dim aComboItems As Variant, i As Long
    
       With VBFlexGrid1
          If (.EditCol = COL_COMBO) And (LenB(.ColComboItems(COL_COMBO))) Then
             aComboItems = Split(.ColComboItems(COL_COMBO), "|")
             For i = LBound(aComboItems) To UBound(aComboItems)
                nNewTextWidth = .TextWidth(aComboItems(i), .EditRow, .EditCol)
                If nTextWidth < nNewTextWidth Then nTextWidth = nNewTextWidth
             Next
             nOldColWidth = .ColWidth(COL_COMBO)
             .ColWidth(COL_COMBO) = nTextWidth \ 15 * 15
             bColWidthIsChanged = True
          End If
       End With
    End Sub
    
    Private Sub VBFlexGrid1_ComboCloseUp()
       If bColWidthIsChanged Then
          VBFlexGrid1.ColWidth(COL_COMBO) = nOldColWidth
          bColWidthIsChanged = False
       End If
    End Sub
    Last edited by Nouyana; Feb 28th, 2024 at 08:58 AM. Reason: Code improvements

  2. #1282
    Lively Member
    Join Date
    May 2022
    Posts
    80

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    But this way the combo with is not changing before opening it, isn't it?

    Add another item at the combo, for example: 'this is a long entry for combo'

    can you see the entire item when you open the combo ?
    Last edited by Calcu; Feb 28th, 2024 at 04:31 AM.

  3. #1283

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,363

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Nouyana View Post
    The only problem is how to identify current drop-down column. In the code below I use the Col property (If .Col = COL_COMBO Then ... ), but this is a bad idea.
    Instead of .Col use the .EditCol property. So just apply .EditRow and .EditCol into the .TextWidth function. Thanks for your assistance.

  4. #1284
    Hyperactive Member
    Join Date
    May 2018
    Location
    Russia
    Posts
    304

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Calcu View Post
    But this way the combo width is not changing before opening it, isn't it?
    Yes.

    Quote Originally Posted by Calcu View Post
    Add another item at the combo, for example: 'this is a long entry for combo'
    can you see the entire item when you open the combo ?
    No. Maybe Krool can improve it.

  5. #1285

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,363

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    You can also enlarge the drop-down list upon EditSetupWindow event via SetWindowPos (pass SWP_NOMOVE SWP_NOACTIVATE etc.)
    Then you see the item while list is dropped down. After the edit you may run an .AutoSize.

  6. #1286
    Addicted Member
    Join Date
    Jan 2012
    Posts
    244

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Hi Krool,

    I noticed that clicking the scrollbar of a grid doesn't set the focus to it, and thus doesn't trigger a lost focus event on a control that was selected before. Is this by design or a bug?

    Regards,
    Erwin

  7. #1287

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,363

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Erwin69 View Post
    Hi Krool,

    I noticed that clicking the scrollbar of a grid doesn't set the focus to it, and thus doesn't trigger a lost focus event on a control that was selected before. Is this by design or a bug?

    Regards,
    Erwin
    That's by design. Why it should be different?

  8. #1288
    Lively Member
    Join Date
    May 2022
    Posts
    80

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Thanks for the answers!

    Will try the editsetupWindow.


    Another question, what way is faster to find "a lot of items"? :-)

    Let me explain.


    I have 2 grids, one has 38566 rows, the other one 14957.

    i want to cross information between them, just check if one value exists on the other grid (in both ways).

    Actually i'm using:

    Code:
    For Linea = 1 To GR1.Rows - 1
    
            Linea2 = GR2.FindItem(GR1.TextMatrix(Linea, GR1.ColIndex("codifica")), 1, GR2.ColIndex("referencia"), FlexFindMatchExact, False, True, False, FlexFindDirectionDown)
    
            If Linea2 >= 1 Then
                GR1.TextMatrix(Linea, GR1.ColIndex("costeenaeu")) = GR2.TextMatrix(Linea2, GR2.ColIndex("costesumado"))
            Else
                GR1.TextMatrix(Linea, GR1.ColIndex("costeenaeu")) = 0
            End If
    
           DoEvents
    
    Next Linea

    it's working fine, but slow, the cells checked are text cells.

    I sorted the results first, in order to be faster, but is still slow.

    Any idea how to do this faster ?

  9. #1289

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,363

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Calcu View Post
    Thanks for the answers!

    Will try the editsetupWindow.


    Another question, what way is faster to find "a lot of items"? :-)

    Let me explain.


    I have 2 grids, one has 38566 rows, the other one 14957.

    i want to cross information between them, just check if one value exists on the other grid (in both ways).

    Actually i'm using:

    Code:
    For Linea = 1 To GR1.Rows - 1
    
            Linea2 = GR2.FindItem(GR1.TextMatrix(Linea, GR1.ColIndex("codifica")), 1, GR2.ColIndex("referencia"), FlexFindMatchExact, False, True, False, FlexFindDirectionDown)
    
            If Linea2 >= 1 Then
                GR1.TextMatrix(Linea, GR1.ColIndex("costeenaeu")) = GR2.TextMatrix(Linea2, GR2.ColIndex("costesumado"))
            Else
                GR1.TextMatrix(Linea, GR1.ColIndex("costeenaeu")) = 0
            End If
    
           DoEvents
    
    Next Linea

    it's working fine, but slow, the cells checked are text cells.

    I sorted the results first, in order to be faster, but is still slow.

    Any idea how to do this faster ?
    Safe the various .ColIndex() results in a variable before the loop.

  10. #1290
    New Member woynpoint's Avatar
    Join Date
    Feb 2024
    Posts
    1

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Krool View Post
    You can also enlarge the drop-down list upon EditSetupWindow event via SetWindowPos (pass SWP_NOMOVE SWP_NOACTIVATE etc.)
    Then you see the item while list is dropped down. After the edit you may run an .AutoSize.
    fethiye tours

    Thanks for information

  11. #1291
    Hyperactive Member
    Join Date
    May 2018
    Location
    Russia
    Posts
    304

    Arrow Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Calcu View Post
    Any idea how to do this faster ?
    1. Use If Linea2 > 0 instead of If Linea2 >= 1
    2. Use If Linea mod 1000 = 0 Then DoEvents instead of just DoEvents
    3. Use With GR1 for the whole loop
    4. TextArray should be faster then TextMatrix
    5. Without "End If" will be a bit faster (If Linea2 > 0 Then ... Else ...)
    6. Use correct datatypes. I mean:
    GR1.TextMatrix(...) = "0"
    If Linea2 > 0& Then
    etc.
    7. Krool's advice

Page 33 of 33 FirstFirst ... 2330313233

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