Page 17 of 17 FirstFirst ... 714151617
Results 641 to 668 of 668

Thread: VBFlexGrid Control (Replacement of the MSFlexGrid control)

  1. #641

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,886

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by softv View Post
    Dear krool,

    This is in continuation of my last message (in which I have requested your clarification on .colsvisible and .rowsvisible).

    And, reg. the various ComboList values, I am sorry that I am not that very clear in my understanding of them.

    So, via the following cases, I am trying to understand them in the right way from you. So, kindly please help.


    Case 1)
    In your VBFlexGrid demo, in UserEditingForm, I have the following lines at the end of the Form_Load event.

    Code:
    Debug.Print VBFlexGrid1.ComboListCount
    Debug.Print VBFlexGrid1.ComboListIndex
    Debug.Print VBFlexGrid1.ComboList(10) & "Z"
    Debug.Print VBFlexGrid1.ColComboItems(10)
    The above print '0', '0', 'Z' and 'Arnold|Bob|Charlie|David|Elena|Felix|Greg|Hanna|Ivan|Jacob'

    a) Why '0' got printed for .ComboListCount? Why .ComboList(10) prints empty string?
    b) Even if I make the rows count as 2 for VBFlexGrid1 and select 'Ivan' (instead of the default Arnold) in both the 10th and 11th columns, then also .ComboListIndex is printed as '0' only. Why?
    c) Perhaps .ComboList, .ComboListCount and .ComboListIndex carry meaning only when they are used in specific events like VBFlexGrid1_EnterEdit(), VBFlexGrid1_LeaveEdit(), etc.? If so, in which all events they carry meaning? Please let me know.


    Case 2)
    At the end of the VBFlexGrid1_EnterEdit() event, I have the following lines.
    Code:
    Debug.Print VBFlexGrid1.ComboListCount
    Debug.Print VBFlexGrid1.ComboListIndex
    '''''Debug.Print VBFlexGrid1.ComboList(10) & "Z"
    Debug.Print VBFlexGrid1.ColComboItems(10)
    And, when I double click a cell in the 10th column where 'Charlie' is present, what get printed are:
    '10', '2' and 'Arnold|Bob|Charlie|David|Elena|Felix|Greg|Hanna|Ivan|Jacob'

    I had to comment out the 3rd line above because it caused a run time error (Invalid procedure call or argument).

    a) Why the 3rd line caused an error? Please educate me. Is it that it cannot or should not be used in certain events?
    b) Where then should (or where all I can) use that line so that it will show some output?
    c) What actually is .ComboList(10) supposed to show? Is it supposed to show the same output of ColComboItems(10) but without the '|' and all the 10 names displayed one after the other, in 10 lines?


    Case 3)
    At the end of the VBFlexGrid1_LeaveEdit() event, I have the following lines.
    Code:
    Debug.Print VBFlexGrid1.ComboListCount
    Debug.Print VBFlexGrid1.ComboListIndex
    'Debug.Print VBFlexGrid1.ComboList(10) & "A"
    Debug.Print VBFlexGrid1.ColComboItems(10)
    VBFlexGrid1.ComboListIndex = 9
    Debug.Print "yes"; VBFlexGrid1.ComboListIndex
    And, when I double click a cell in the 10th column where Charlie is present and select Charlie itself again, what get printed are:
    '10', '2', 'Arnold|Bob|Charlie|David|Elena|Felix|Greg|Hanna|Ivan|Jacob' and 'yes 9'

    a) I had to keep the 3rd line commented out here also since it caused the same run time error (Invalid procedure call or argument).
    b) Though I changed the .ComboListIndex to 9, the selection remained at 'Charlie' only.
    c) So, where and how should I use .ComboListIndex so that I can "programmatically" change/select the ComboList item in any cell in the 10th column (ComboDropDown) without having to manually double click a cell and select a particular item in the list.


    Thanks a TON once again for your contribution to the world society.

    Kind regards.
    ColComboItems is similar to the ComboItems property, except it applies to entire columns. This is often more convenient that using the ComboItems property because you may set the ColComboItems property once for each column, whereas the ComboItems property normally needs to be set in the BeforeEdit event.

    ComboListCount, ComboListIndex and ComboList(x) are properties to extract info from a once defined ColComboItems/ComboItems.

    So, ComboList(x) is to extract x entry for the current column. X is not the column, that's why you had an error.

  2. #642
    Lively Member
    Join Date
    Apr 2017
    Location
    India
    Posts
    90

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Dear krool,

    As in the case of 'sort', is it possible to show a chevron (inside a square preferably) by the side of the cells of the column whose .ColComboMode is set to FlexComboModeDropDown (or) FlexComboModeEditable? Because, this way, a user will readily know that there is a ComboList existing in the cells of that column.

    If the above is not possible, then what is the easiest way to indicate to the user by text that there is a ComboList existing in those cells? Anyway, since indication via picture is the best way, what is the easiest way to make a chevron get displayed by the side of all such ComboList cells? Draw a picture using ".Cell(FlexCellPicture)"? If so, what would be the best way to draw the chevron pictures so that they appear correctly in all resolutions, etc.? And, will it be possible to act upon click events on those chevron pictures? If not, capturing mouse click events on X,Y coordinates of those chevrons is the only way? Well, any suggestions are welcome. Thanks in advance.

    Kind regards.

  3. #643
    Lively Member
    Join Date
    Apr 2017
    Location
    India
    Posts
    90

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Krool View Post
    ColComboItems is similar to the ComboItems property, except it applies to entire columns. This is often more convenient that using the ComboItems property because you may set the ColComboItems property once for each column, whereas the ComboItems property normally needs to be set in the BeforeEdit event.

    ComboListCount, ComboListIndex and ComboList(x) are properties to extract info from a once defined ColComboItems/ComboItems.

    So, ComboList(x) is to extract x entry for the current column. X is not the column, that's why you had an error.
    ComboList(x). Thanks a lot, krool. Understood. I think I have understood difference between ColComboItems and ComboItems too. If there are doubts, I shall write again.

    As of now, can you kindly let me know whether it is possible to programmatically change/select the ComboList item in any cell of a column whose ColComboMode is set to FlexComboModeDropDown (or FlexComboModeEditable)? If so, can you kindly give me a code sample please?

    Kind regards.
    Last edited by softv; Oct 9th, 2021 at 10:54 AM.

  4. #644

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,886

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by softv View Post
    ComboList(x). Thanks a lot, krool. Understood. I think I have understood difference between ColComboItems and ComboItems too. If there are doubts, I shall write again.

    As of now, can you kindly let me know whether it is possible to programmatically change/select the ComboList item in any cell of a column whose ColComboMode is set to FlexComboModeDropDown (or FlexComboModeEditable)? If so, can you kindly give me a code sample please?

    Kind regards.
    Use ComboListIndex to change the selected list item.

  5. #645
    Lively Member
    Join Date
    Apr 2017
    Location
    India
    Posts
    90

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Krool View Post
    Use ComboListIndex to change the selected list item.
    I had already tried it but did not succeed. But, after seeing your instruction, I tried again and achieved it. Thanks a TON.

    However, I request you to tell me whether there is a better way to achieve it than the way I have adopted below. The code I used (in a button click) was:
    Code:
      With VBFlexGrid1
        .Row = 2
        .Col = 10
        .StartEdit
        .ComboListIndex = 5
        '''''.CommitEdit
      End With
      SendKeys vbLf
    The above worked like a charm, to programmatically select a list item. Thanks a TON once again.
    But, I feel there must be a better alternative to 'SendKeys vbLf'.
    That's why I tried VBFlexGrid1.CommitEdit, but it did not change the ComboListIndex to 5. The dropdown just closed. Kindly suggest me an alternative to 'SendKeys vbLf', if any. Thanks in advance.

    Kind regards.

  6. #646

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,886

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by softv View Post
    I had already tried it but did not succeed. But, after seeing your instruction, I tried again and achieved it. Thanks a TON.

    However, I request you to tell me whether there is a better way to achieve it than the way I have adopted below. The code I used (in a button click) was:
    Code:
      With VBFlexGrid1
        .Row = 2
        .Col = 10
        .StartEdit
        .ComboListIndex = 5
        '''''.CommitEdit
      End With
      SendKeys vbLf
    The above worked like a charm, to programmatically select a list item. Thanks a TON once again.
    But, I feel there must be a better alternative to 'SendKeys vbLf'.
    That's why I tried VBFlexGrid1.CommitEdit, but it did not change the ComboListIndex to 5. The dropdown just closed. Kindly suggest me an alternative to 'SendKeys vbLf', if any. Thanks in advance.

    Kind regards.
    The .ComboListIndex = 5 works as it should. What do you want to achieve, to just avoid user selection and commit list entry 5 ?
    The below code will do it without SendKeys vbLf...
    Code:
    VBFlexGrid1.EditText = VBFlexGrid1.ComboList(5)
    VBFlexGrid1.CommitEdit

  7. #647
    Lively Member
    Join Date
    Apr 2017
    Location
    India
    Posts
    90

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Krool View Post
    ... .. .
    The below code will do it without SendKeys vbLf...
    Code:
    VBFlexGrid1.EditText = VBFlexGrid1.ComboList(5)
    VBFlexGrid1.CommitEdit
    Perfect, Krool. Thank you so much.

    Kind regards.

  8. #648
    Lively Member
    Join Date
    Apr 2017
    Location
    India
    Posts
    90

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Dear krool,

    is it possible to freeze rows (one or more) from the bottom rows of a grid? If so, what should I do? Thanks.

    As of now, just to freeze the very last row of the grid is enough for me so that when user scrolls up and down, the last row is always visible.

    Kind regards.

  9. #649

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,886

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by softv View Post
    Dear krool,

    is it possible to freeze rows (one or more) from the bottom rows of a grid? If so, what should I do? Thanks.

    As of now, just to freeze the very last row of the grid is enough for me so that when user scrolls up and down, the last row is always visible.

    Kind regards.
    Not possible. Even Excel doesn't allow it.
    What you want actually? Maybe there is an alternative..

  10. #650
    Lively Member
    Join Date
    Apr 2017
    Location
    India
    Posts
    90

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Krool View Post
    Not possible. Even Excel doesn't allow it.
    What you want actually? Maybe there is an alternative..
    Oh okay, krool. Understood.

    I just wanted to show the number of records (at any point of time in the grid) in the last row of the grid itself.
    Right now, I am using an alternative only. I am showing the records count in a separate control placed below the grid. If there is a better alternative, kindly let me know.

    I just felt that showing the records count (which will be just .rows-1, in my grid's case) inside the grid itself in a frozen last row will be ideal. That's all.

    Kind regards.
    Last edited by softv; Oct 10th, 2021 at 02:25 AM.

  11. #651

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,886

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by softv View Post
    Dear krool,

    As in the case of 'sort', is it possible to show a chevron (inside a square preferably) by the side of the cells of the column whose .ColComboMode is set to FlexComboModeDropDown (or) FlexComboModeEditable? Because, this way, a user will readily know that there is a ComboList existing in the cells of that column.

    If the above is not possible, then what is the easiest way to indicate to the user by text that there is a ComboList existing in those cells? Anyway, since indication via picture is the best way, what is the easiest way to make a chevron get displayed by the side of all such ComboList cells? Draw a picture using ".Cell(FlexCellPicture)"? If so, what would be the best way to draw the chevron pictures so that they appear correctly in all resolutions, etc.? And, will it be possible to act upon click events on those chevron pictures? If not, capturing mouse click events on X,Y coordinates of those chevrons is the only way? Well, any suggestions are welcome. Thanks in advance.

    Kind regards.
    There is no "picture click" event.
    What's the use-case you want to achieve?

  12. #652
    Lively Member
    Join Date
    Apr 2017
    Location
    India
    Posts
    90

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Krool View Post
    There is no "picture click" event.
    What's the use-case you want to achieve?
    Dear krool,

    As written earlier, the use-case is for the user to readily know that a drop down list is present in the cells of a particular column. Obviously, I cannot have column names as DropDown Combo, etc. So, there should be some pictorial indication somewhere to the user so that he knows immediately on seeing the grid that there is a drop down available in the cells of a particular column. Any kind of suggestions towards achieving this (in whatever manners possible) is welcome. Thanks in advance.

    Kind regards.

  13. #653

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,886

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Update released.

    Quote Originally Posted by TheLeePiper View Post
    In short, is there a way to land on a cell that has been set as a dropdown combo and have it not drop the list, just shot the text and the button. (We are hoping to use this as a container for editable fields of a variety of different types. Thanks!
    The workaround with .ComboButtonValue to 'FlexComboButtonValueDisabled' is not needed anymore. There is a new event now 'ComboBeforeDropDown'.
    So you can achieve the wanted behavior now easily by following code:

    Code:
    Private Sub VBFlexGrid1_ComboBeforeDropDown(ByVal Reason As FlexComboDropDownReasonConstants, Cancel As Boolean)
    If Reason = FlexComboDropDownReasonInitialize Then Cancel = True
    End Sub

  14. #654

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,886

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by softv View Post
    Dear krool,

    As written earlier, the use-case is for the user to readily know that a drop down list is present in the cells of a particular column. Obviously, I cannot have column names as DropDown Combo, etc. So, there should be some pictorial indication somewhere to the user so that he knows immediately on seeing the grid that there is a drop down available in the cells of a particular column. Any kind of suggestions towards achieving this (in whatever manners possible) is welcome. Thanks in advance.

    Kind regards.
    That's an interesting question. So, a visual cue that a dropdown will appear when attempting to edit.
    The not disturbing approach would be not to always show such a "chevron" but only when that cell is selected. Using the RowColChange event.
    However, using a picture with right align and no overlap would be the easiest and dynamically set/clear upon RowColChange.
    Difficult part is to create such a dynamic scaled picture at run-time. (Using DrawFrameControl etc.)

  15. #655
    Junior Member
    Join Date
    Jan 2017
    Location
    British Columbia
    Posts
    21

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Krool View Post
    Yes great. Thanks

    You migrate 1.4 OCX version?
    Do you include bugfixes? Like yesterday fixes.
    When 1.5 OCX version comes out you migrate also?
    I have suspended work on the VBFlexGrid.NET for now and have pivoted to migrating the VBFlexGrid to a native ActiveX control written with C++ and ATL.

    A native ActiveX control should work better with traditional ActiveX consumers like VB6, there being no interop or .NET Framework issues, while providing 64-bit compatibility for modern Office.

    RD

  16. #656

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,886

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Update released.

    Included the ColSortArrowAlignment property, which is either left or right (default). This way it's explicit and cleaner.

    Also, there was a bug in the DoubleBuffer property when changing RightToLeft/RightToLeftLayout at run-time.
    Name:  FlexRTLLayoutBug.jpg
Views: 166
Size:  30.4 KB
    The DoubleBufferDC is initially correctly setup thanks to CreateCompatibleDC. However, when the layout changes to RTL then the DoubleBufferDC was not updated.
    Now, it's set via SetLayout API to LAYOUT_RTL or 0 on WM_STYLECHANGED to fix this.

  17. #657

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,886

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    I'm having the idea of including a 'ComboModeCalendar' which has as drop-down client a SysMonthCal32.
    However, parsing the date to the MonthView is done with IsDate() and CDate(). If date is invalid it has then today's date as current selection in the drop-down window.
    Problem is how to put back the date into text?

    I'm thinking of a ComboFormat property which can be set. If empty it just passes Text = Date. Else uses Format$().

    Or is it too much and discard the idea? The vsFlexGrid also does not have it.
    Though I could find useful use for such a mode..
    Last edited by Krool; Oct 22nd, 2021 at 02:14 AM. Reason: DTPicker changed to Calendar (date only - popup calendar)

  18. #658
    Hyperactive Member
    Join Date
    Aug 2016
    Posts
    355

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Krool View Post
    I'm having the idea of including a 'ComboModeDTPicker' which has as drop-down client a SysMonthCal32.
    However, parsing the date to the MonthView is done with IsDate() and CDate(). If date is invalid it has then today's date as current selection in the drop-down window.
    Problem is how to put back the date into text?

    I'm thinking of a ComboFormat property which can be set. If empty it just passes Text = Date. Else uses Format$().

    Or is it too much and discard the idea? The vsFlexGrid also does not have it.
    Though I could find useful use for such a mode..
    I suggest a public enum and Format$ with an optional separator string "-" or "/":
    Code:
    Public Enum DateFormatEnum
    
        YMD = 0 'YYYY-MM-DD
        MDY = 1 'MM-DD-YYYY
        DMY = 2 'DD-MM-YYYY
        System = 3
    
    End Enum

  19. #659

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,886

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by DaveDavis View Post
    I suggest a public enum and Format$ with an optional separator string "-" or "/":
    Code:
    Public Enum DateFormatEnum
    
        YMD = 0 'YYYY-MM-DD
        MDY = 1 'MM-DD-YYYY
        DMY = 2 'DD-MM-YYYY
        System = 3
    
    End Enum
    Thanks for feedback. I may consider just to cast .EditText = Date from the calendar. (System format then)
    The app can use the ValidateEdit event to modify .EditText with a Format of choice before the commit to the cell is done.

  20. #660

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,886

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Update released.

    Included enum FlexComboModeCalendar.

    Name:  FlexCalendarValidation.png
Views: 100
Size:  9.3 KB

    To ensure unique format you may put following in ValidateEdit event.
    Code:
    If Cancel = False Then
        ' Ensure unique date format before commit. (override possible custom format of the text box)
        VBFlexGrid1.EditText = VBFlexGrid1.ComboCalendarValue
    End If
    Beside ComboCalendarValue, there is also ComboCalendarMinDate/ComboCalendarMaxDate available.

  21. #661
    Lively Member
    Join Date
    Apr 2017
    Location
    India
    Posts
    90

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Krool View Post
    Update released.

    Included enum FlexComboModeCalendar.

    ... .. .

    To ensure unique format you may put following in ValidateEdit event.
    Code:
    If Cancel = False Then
        ' Ensure unique date format before commit. (override possible custom format of the text box)
        VBFlexGrid1.EditText = VBFlexGrid1.ComboCalendarValue
    End If
    Beside ComboCalendarValue, there is also ComboCalendarMinDate/ComboCalendarMaxDate available.
    Amazing, Krool. The project I am currently working on involves having dates in combo columns. While I was happy filling the combo column cells with dates itself, you have provided a calendar too additionally! Wow!!! Thanks a TON. I think I will be able to find a case to avail the calendar combo too in my project now!

    Kind regards.

  22. #662
    Lively Member
    Join Date
    Apr 2017
    Location
    India
    Posts
    90

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Krool View Post
    That's an interesting question. So, a visual cue that a dropdown will appear when attempting to edit.
    The not disturbing approach would be not to always show such a "chevron" but only when that cell is selected. Using the RowColChange event.
    However, using a picture with right align and no overlap would be the easiest and dynamically set/clear upon RowColChange.
    Difficult part is to create such a dynamic scaled picture at run-time. (Using DrawFrameControl etc.)
    With respect to the above, can there be a boolean property in the vbFlexGrid (say 'ComboVisualCue') so that making it true will show the chevron while mouse hovers on the combo cells? Well, I understand the difficulty factor you mention in drawing the chevron during run-time, but since it is just for one cell only at any point of time, if and when you hit upon a way to achieve drawing the 'dynamically scaled' chevron in an easier manner, you may kindly think of my suggestion for a ComboVisualCue property. Thanks in advance.

    And, I take this opportunity to once again thank you for the UseCrLf property in RichTextBox.

    Kind regards.
    Last edited by softv; Oct 24th, 2021 at 09:24 AM.

  23. #663
    Lively Member
    Join Date
    Apr 2017
    Location
    India
    Posts
    90

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by softv View Post
    Dear krool,

    ... .. . Object browser told me that .colsvisible "Returns the total number of columns or rows visible in the flex grid."

    To understand the above statement from the Object Browser better, I just experimented with a sample 10*10 flex grid. I realised that even if I hide some columns (say 1, 2 and 3) and reduce the width of the grid to show only 2 columns (i.e. only column 0 and column 4), then also .colsvisible will return 5 and not 2. Is it so by design? Just a clarification. Thats all.

    .rowsvisible also behaves similarly with a similar experiment as above. So, just wanted to clarify whether .colsvisible and .rowsvisible are designed to report values in the above manner only. ... .. .
    I await your clarification on the above, Krool. In other words, suppose I have 20 columns in a grid; I set '.ColHidden = True' for columns 2 to 19; make columns 1 and 20 only visible to user, then also .ColsVisible reports 20 and not 2? Is that correct?

    Kind regards.

  24. #664

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,886

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by softv View Post
    I await your clarification on the above, Krool. In other words, suppose I have 20 columns in a grid; I set '.ColHidden = True' for columns 2 to 19; make columns 1 and 20 only visible to user, then also .ColsVisible reports 20 and not 2? Is that correct?

    Kind regards.
    20 are count before the first "non-visible".
    Technically it is correct. What's your need?

  25. #665
    Lively Member
    Join Date
    Apr 2017
    Location
    India
    Posts
    90

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Krool View Post
    20 are count before the first "non-visible".
    Technically it is correct. What's your need?
    Dear Krool,

    Kindly please consider the 2 cases (Case 1 and Case 2) in the following code, for a 20 columns grid. As mentioned by me (in two of the comments in the following code), .ColsVisible prints "20" in both cases, whereas logically I was expecting only "2" to be printed, since I have hidden the other 18 columns. In other words, in my form itself, only 2 columns from the grid will be visible in both the cases.

    So, I am honestly not able to understand why .ColsVisible should print "20" and not "2"? Is printing "20" only technically correct by design itself? I mean, .ColsVisible will always ignore hidden columns in its count? I just want your clarification/confirmation on this. Thanks.

    Code:
      For i = 2 To 19 'i.e. I have made 0th and 1st indexed columns alone to be visible in the grid. I have kept other columns hidden by setting .ColHidden = true for them
        flx1000.ColHidden(i) = True
      Next i
      flx1000.TextMatrix(0, 0) = "Column 0"
      flx1000.TextMatrix(0, 1) = "Column 1"
      Debug.Print vbCrLf
      Debug.Print "No. of visible columns in flx1000, in Case 1 = ", flx1000.ColsVisible
      'the above prints "20" and not "2"
      
      With flx1000
        .ColHidden(.Cols - 1) = False '19th indexed column is made visible again
        For i = 1 To 18 'i.e. I have made 0th and 19th indexed columns (in other words, first and last columns) alone to be visible in the grid. I have kept 1st to 18th indexed columns hidden
          .ColHidden(i) = True
        Next i
        .TextMatrix(0, 0) = "Column 0"
        .TextMatrix(0, 19) = "Column 19"
      End With
      Debug.Print "No. of visible columns in flx1000, in Case 2 = ", flx1000.ColsVisible
      'the above also prints "20" and not "2"
    Kind regards.

    EDIT-1 (to add further more clarity [hopefully] to my query):
    Suppose my code is just the following one line alone (i.e. completely ignoring the above code and the 2 cases in it), then, if I keep the width of my 20 columns grid in such a way that the first 2 columns alone are fully visible in my form, then flx1000.ColsVisible prints "2" which is correct, because out of the 20 columns, I have kept the width of the grid in such a way that the first 2 columns alone are fully visible in my form.
    Code:
      Debug.Print "No. of visible columns in flx1000 = ", flx1000.ColsVisible
      'this prints "2" which is correct

    Now, suppose I keep the width of my 20 columns grid in such a way that the first 5 columns alone are fully visible in my form. Then, flx1000.ColsVisible prints "5" which is again correct, because out of the 20 columns, I have kept the grid's width in such a way that the first 5 columns (0th to 4th indexed columns) alone are fully visible in my form.


    But, if I hide columns 1 to 2 (i.e. for 1st and 2nd indexed columns, I set .ColHidden = True) and keep the width of my 20 columns grid in such a way that only 5 columns are visible (i.e. the 0th, 3rd, 4th, 5th and 6th indexed columns are only fully visible), then flx1000.ColsVisible prints "7" (and not "5") which, personally for me, sounds logically incorrect since I have already kept the width of the grid in such a way that only 5 columns are fully visible. Please see screenshot below.

    Name:  ColsVisible.png
Views: 53
Size:  940 Bytes

    The thing is that though ".ColHidden" has been set to "True" for 1st and 2nd indexed columns, they have also been included in the .ColsVisible count. Please see code below. But, if this is how .ColsVisible is set to behave technically, by design, then no issues at all. But, I just wanted a confirmation on that. That's all. Nothing else. Thanks.

    Code:
      With flx1000
        For i = 1 To 2
          .ColHidden(i) = True
        Next i
        .TextMatrix(0, 0) = "Column 0"
        .TextMatrix(0, 1) = "Column 1"
        .TextMatrix(0, 2) = "Column 2"
        .TextMatrix(0, 3) = "Column 3"
        .TextMatrix(0, 4) = "Column 4"
        .TextMatrix(0, 5) = "Column 5"
        .TextMatrix(0, 6) = "Column 6"
        Debug.Print vbCrLf, Now
        Debug.Print "No. of visible columns in flx1000 = ", .ColsVisible
      End With
      'the above prints 7 and not 5
    Kind Regards.
    Last edited by softv; Oct 25th, 2021 at 10:46 AM.

  26. #666

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2012
    Posts
    1,886

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by softv View Post
    Dear Krool,

    Kindly please consider the 2 cases (Case 1 and Case 2) in the following code, for a 20 columns grid. As mentioned by me (in two of the comments in the following code), .ColsVisible prints "20" in both cases, whereas logically I was expecting only "2" to be printed, since I have hidden the other 18 columns. In other words, in my form itself, only 2 columns from the grid will be visible in both the cases.

    So, I am honestly not able to understand why .ColsVisible should print "20" and not "2"? Is printing "20" only technically correct by design itself? I mean, .ColsVisible will always ignore hidden columns in its count? I just want your clarification/confirmation on this. Thanks.

    Code:
      For i = 2 To 19 'i.e. I have made 0th and 1st indexed columns alone to be visible in the grid. I have kept other columns hidden by setting .ColHidden = true for them
        flx1000.ColHidden(i) = True
      Next i
      flx1000.TextMatrix(0, 0) = "Column 0"
      flx1000.TextMatrix(0, 1) = "Column 1"
      Debug.Print vbCrLf
      Debug.Print "No. of visible columns in flx1000, in Case 1 = ", flx1000.ColsVisible
      'the above prints "20" and not "2"
      
      With flx1000
        .ColHidden(.Cols - 1) = False '19th indexed column is made visible again
        For i = 1 To 18 'i.e. I have made 0th and 19th indexed columns (in other words, first and last columns) alone to be visible in the grid. I have kept 1st to 18th indexed columns hidden
          .ColHidden(i) = True
        Next i
        .TextMatrix(0, 0) = "Column 0"
        .TextMatrix(0, 19) = "Column 19"
      End With
      Debug.Print "No. of visible columns in flx1000, in Case 2 = ", flx1000.ColsVisible
      'the above also prints "20" and not "2"
    Kind regards.

    EDIT-1 (to add further more clarity [hopefully] to my query):
    Suppose my code is just the following one line alone (i.e. completely ignoring the above code and the 2 cases in it), then, if I keep the width of my 20 columns grid in such a way that the first 2 columns alone are fully visible in my form, then flx1000.ColsVisible prints "2" which is correct, because out of the 20 columns, I have kept the width of the grid in such a way that the first 2 columns alone are fully visible in my form.
    Code:
      Debug.Print "No. of visible columns in flx1000 = ", flx1000.ColsVisible
      'this prints "2" which is correct

    Now, suppose I keep the width of my 20 columns grid in such a way that the first 5 columns alone are fully visible in my form. Then, flx1000.ColsVisible prints "5" which is again correct, because out of the 20 columns, I have kept the grid's width in such a way that the first 5 columns (0th to 4th indexed columns) alone are fully visible in my form.


    But, if I hide columns 1 to 2 (i.e. for 1st and 2nd indexed columns, I set .ColHidden = True) and keep the width of my 20 columns grid in such a way that only 5 columns are visible (i.e. the 0th, 3rd, 4th, 5th and 6th indexed columns are only fully visible), then flx1000.ColsVisible prints "7" (and not "5") which, personally for me, sounds logically incorrect since I have already kept the width of the grid in such a way that only 5 columns are fully visible. Please see screenshot below.

    Name:  ColsVisible.png
Views: 53
Size:  940 Bytes

    The thing is that though ".ColHidden" has been set to "True" for 1st and 2nd indexed columns, they have also been included in the .ColsVisible count. Please see code below. But, if this is how .ColsVisible is set to behave technically, by design, then no issues at all. But, I just wanted a confirmation on that. That's all. Nothing else. Thanks.

    Code:
      With flx1000
        For i = 1 To 2
          .ColHidden(i) = True
        Next i
        .TextMatrix(0, 0) = "Column 0"
        .TextMatrix(0, 1) = "Column 1"
        .TextMatrix(0, 2) = "Column 2"
        .TextMatrix(0, 3) = "Column 3"
        .TextMatrix(0, 4) = "Column 4"
        .TextMatrix(0, 5) = "Column 5"
        .TextMatrix(0, 6) = "Column 6"
        Debug.Print vbCrLf, Now
        Debug.Print "No. of visible columns in flx1000 = ", .ColsVisible
      End With
      'the above prints 7 and not 5
    Kind Regards.
    That's discuss-able what is "correct".
    However, the behavior is similar to the .ColIsVisible property.
    Check this out in MS(H)FlexGrid what it prints on a column that is "hidden" (ColWidth = 0) but between two "visible" cols.
    It returns True..

  27. #667
    Lively Member
    Join Date
    Apr 2017
    Location
    India
    Posts
    90

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Quote Originally Posted by Krool View Post
    That's discuss-able what is "correct".
    However, the behavior is similar to the .ColIsVisible property.
    Check this out in MS(H)FlexGrid what it prints on a column that is "hidden" (ColWidth = 0) but between two "visible" cols.
    It returns True..
    Oh okay, Krool. So, it is like that, by design. Understood. No issues then. Thanks a TON.

    Kind regards.

  28. #668
    Junior Member
    Join Date
    Jan 2017
    Location
    British Columbia
    Posts
    21

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Deleted
    Last edited by R.J. Dunnill; Yesterday at 01:00 PM.

Page 17 of 17 FirstFirst ... 714151617

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