FlexGrid Cell Vertical Scroll

Posted by: softcomlimited on 12 September 2019, 3:05 am EST

    • Post Options:
    • Link

    Posted 12 September 2019, 3:05 am EST

    Hello,

    Is there a way to have a vertical scroll on a read-only cell with multiple lines of text?

    I can set the editor to be a textbox with multiline and vertical scroll and that is perfect for editing.

    However my grid needs to have previously entered rows readonly and I need the vscroll in those cells without going into editmode.

    I don’t want the rows to autosize to show everything. I want them a fixed height so the user can see the first 2 or 3 lines and just scroll the cell if they want to see the rest.

    Regards

    Brian

  • Posted 12 September 2019, 6:47 pm EST

    Hi Brian,

    attached is a sample which hopefully resolves your requirement.

    FlexScrollableText.zip

    I use a TextBox to display the cell text. This textbox is a child control of the flexgrid and the location/size is synchronized with the selected cell.

    Hope this helps

    Wolfgang

  • Posted 12 September 2019, 7:47 pm EST

    Hello Brian,

    To scroll in non editable cell of FlexGrid you can use one of the two solutions given below :

    1 : You can use the HostControl as textbox for non editible cells. To know how to use HostControls in FlexGrid please refere to the sample HostControls in the Product sample list at location : \Documents\ComponentOne Samples\WinForms\v4.0\C1FlexGrid\CS\HostControls

    I have done some modifications to make the sample work as per your need, please have a look.

    ReadOnlyCellScrollDemoFlexGrid.zip

    2 : You can follow the approach of taking TextBox as a child control of FlexGrid as suggested by @Wolfgang.

    FlexScrollableText.zip

    @Wolfgang, thank you for the sample and explanation. I have just added some part of code to hide the caret sign in the readonly textbox cell.

    Regards,

    Prabhat Sharma.

  • Posted 12 September 2019, 11:04 pm EST

    Thank you very much both of you.

    Brian

  • Posted 12 September 2019, 11:52 pm EST

    Mr Sharma,

    I see what you are doing and I looked at the \Documents\ComponentOne Samples\WinForms\v4.0\C1FlexGrid\CS\HostControls so I will try and put it together.

    Is there some reason the HostControls sample is only in CS and not also as VB ?

    Regards

    Brian

  • Posted 13 September 2019, 1:10 am EST

    Mr Sharma,

    I am trying to run your example which has the flexgrid bound to a datasource but it is not working because i don’t have that cars table. Can you send me a copy of that table please?

    I see in the HostControls sample that a button can be hosted. Can it have a button for each row? Do you then have a button_click event or a cell_click event? In the case of the tab control you would have some textboxes on each tab, how do you reference each of the textboxes for each row and how would they be linked to the datasource?

    Regards

    Brian

  • Posted 13 September 2019, 1:43 am EST

    Mr Sharma, Wolfgang,

    I was able to get both of your samples to work, for some reason all the column widths were -1 and I had to manually set them to 100 so that something is displayed.

    Mr Sharma, in your example the cells do not show the text multiline until you click in the cell, unlike in Wolfgang’s example which perfectly shows as much as possible. I am leaning towards your example as it would also solve my problem when I allow the user to edit the cell. Is it that I need to use both methods?

    Regards

    Brian

  • Posted 13 September 2019, 3:20 am EST

    Mr Sharma,

    I got it, it was just the style that needing fixing.

    Thanks a lot!

    Brian

  • Posted 15 September 2019, 9:55 pm EST

    Hello Brian,



    Most ComponentOne product samples are available in c# and vb, both. However, based on requirements new samples are also added to this list. So, there are chances that earlier HostControl sample was requested only in c#, hence its vb counterpart does not exist.

    Anyhow, since you want the corresponding vb sample, I have attached it here.

    Additionally, I have also send a request to include the same in product samples as well.

    I have also converted the WolfGang’s sample in VB.net for you, please have a look.​

    FlexScrollableVBDemo.zip

    ReadOnlyCellScrollVBDemo.zip



    >>I am trying to run your example which has the flexgrid bound to a datasource but it is not working because i don’t have that cars table

    That Cars table is in the C1NWind Access database which can be found in your system at location: ​\Documents\ComponentOne Samples\Common\C1NWind.mdb​



    >>Can it have a button for each row? Do you then have a button_click event or a cell_click event?

    When Button is used as host control for any cell and is clicked, it’s Click event is fired because at that time the active control which is being interacted is button.​



    >>In the case of the tab control you would have some textboxes on each tab, how do you reference each of the textboxes for each row and how would they be linked to the datasource?

    You can set the text on the TextBoxes in different tabs in the TabIndexChanged event of TabControl as per the selection of the cell.​

    Regards,

    Prabhat Sharma.

  • Posted 16 September 2019, 12:27 am EST - Updated 3 October 2022, 3:46 pm EST

    Mr Sharma,

    I had figured it out, but thanks for the vb samples anyway.

    I had meant the the Cars table is not in my copy of C1NWind mdb, it has products, customers etc but no cars. It is probably in a version higher than my 2015 version. Not a problem.

    With regard to referencing each of the textboxes on the tabcontrol and binding, I was trying to ask if they can possibly be bound to fields in the datasource of the grid or if I have to manually populate them?

    I am looking for a possible way to put multiple fields in one cell in a fashion similar to using a continuous form in an MS Access screen that I am trying to duplicate (see attached). I was thinking of using a tabcontrol with 1 tab and the controls on that.

    Thanks

    Brian Morris

  • Posted 16 September 2019, 4:54 pm EST

    Hello,

    Sorry, there is no direct method to bind the host controls with the database.

    You need to populate it manually according to the indexes in the Database.

    Regards,

    Prabhat Sharma.

  • Posted 16 September 2019, 9:20 pm EST

    Hi Brian,

    if you want to reuse the old control design, you might better work without a C1FlexGrid. Just create a UserControl which contains all controls for one data item.

    When you build the list of items, create an instance of this user control for each item and add it to a “Panel”. All user controls should have Dock = Top.

    This way you are near to the old UI, and you don’t need many workarounds to C1FlexGrid.

    But this approach has performance problems if you have a lot of items in the list - so it is not perfect…

    Best regards

    Wolfgang

  • Posted 17 September 2019, 1:13 am EST

    No, I don’t want performance problems. It is amazing that MS created both Access and VS and what is so easy in Access is such a challenge in VS.

    Oh well, we will just have to change to what is possible in VS.

    Thank you both for your input.

    Brian

  • Posted 23 September 2019, 6:30 am EST

    Mr Sharma,

    In the ReadOnlyCellScrollVBDemo.zip example how do you allow the user to tab out to the next cell when they are finished editing? At the moment you must use the mouse to click. I tried using AcceptsTab=False but that did not work.

    Thank you

    Brian

  • Posted 23 September 2019, 2:33 pm EST

    Hello Brian,

    You just need to use the KeyActionTab property of FlexGrid to achieve the desired result as given in code snippet below :

    //To move to the next column
    c1FlexGrid1.KeyActionTab = KeyActionEnum.MoveAcross
    
    //To move to the next row
    c1FlexGrid1.KeyActionTab = KeyActionEnum.MoveDown
    

    I hope it helps.

    Regards,

    Prabhat Sharma.

  • Posted 24 September 2019, 2:29 am EST

    Ok, thanks, I will try this.

    Regards

    Brian

  • Posted 25 September 2019, 11:45 pm EST

    Mr Sharma

    It works fine except when we have a textbox as the editor, it just tabs within the textbox once you start editing. Did we miss something?

    Regards

    Brian

  • Posted 26 September 2019, 2:27 pm EST

    Hello Brian,

    Sorry but we could not replicate the issue at our end with the last attached sample in Tabbing out of the cell by pressing Tab key with the following properties :

    //To move to the next column
    c1FlexGrid1.KeyActionTab = KeyActionEnum.MoveAcross
    
    //To move to the next row
    c1FlexGrid1.KeyActionTab = KeyActionEnum.MoveDown
    

    I am attaching a GIF file showing the same as mentioned above, please have a look.

    If you are using any other sample and facing the issue so please share the stripped down sample replicating the issue. You can also modify and attach the above given sample replicating the issue.

    Regards,

    Prabhat Sharma.

  • Posted 26 September 2019, 11:03 pm EST

    Mr Sharma,

    The sample with tabbing out that you refer to is ReadOnlyCellScrollVBDemo.zip ?

    I am not seeing the GIF.

    Regards

    Brian

  • Posted 27 September 2019, 4:44 am EST

    Mr Sharma,

    I am getting the tab action but you have to press tab 3 or 4 times before you get from editing text in the cell to moving to the next cell. I attach the sample where the ContactName column is to be edited.

    Regards

    Brian

    ReadOnlyCellScrollVBDemo.zip

  • Posted 29 September 2019, 3:42 pm EST - Updated 3 October 2022, 3:46 pm EST

    Hello,

    Sorry for missing the attachment. Here is the GIF file attached.

    You are using HostControl for the cell that you are editing so the tab action triggers for that HostControl first then for the FlexGrid cell that is why it is moving to next cell after multiple clicks.

    I will recommend you to use TextBox as Editor in SetupEditor event of FlexGrid for editable cells as implemented in the ReadOnlyCellScrollVBDemo.zip sample before for the desired behavior.

    Regards,

    Prabhat Sharma.

  • Posted 30 September 2019, 1:01 am EST

    Mr Sharma,

    ok, thanks, I will try that.

    Regards

    Brian Morris

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels