Combobox CellType with custom subeditor

Posted by: matthias_gaertner on 16 May 2019, 4:28 pm EST

    • Post Options:
    • Link

    Posted 16 May 2019, 4:28 pm EST

    Hello guys,

    I´m looking for a non editable (Editable = false) combobox opening a custom subeditor when clicking on the dropdown button of the combobox.

    I´ve tried this with a std. combobox celltype and a custom subeditor (derived from UserControl and ISubEditor). But this does not work. Clicking the dropdown button does not open the subeditor.

    So I´ve tried a derived textcelltype ```

    public class IST_TextCellTypeWithSubEditor : TextCellType

    {

    public override System.Windows.Forms.Control GetEditorControl(System.Windows.Forms.Control parent, FarPoint.Win.Spread.Appearance appearance, float zoomFactor)

    {

    System.Windows.Forms.Control myControl = base.GetEditorControl(parent, appearance, zoomFactor);

    ((GeneralEditor)myControl).ButtonStyle = FarPoint.Win.ButtonStyle.DropDown;

    return myControl;

    }

    }

    with the same subeditor and this works nearly perfectly. Clicking the dropdown button opens the subeditor. 
    BUT I found no property to set the textcelltype to non-editable (of course the dropdown button must be clickable...).
    
    Any ideas about that.
    
    Regards
    Matthias
  • Posted 16 May 2019, 4:29 pm EST

    I forgot to say that I´m currently using Spread.Net v6.0.3503.2008. Version 12 is available but not used in our company.

  • Posted 19 May 2019, 10:27 pm EST

    Hello,

    Sorry to mention that Spread6 was declared a legacy product a long time ago. It is out of maintenance mode now. Hence, we do not provide support for the same. I would recommend you to use the latest version of ActiveReportsServer i.e Spread 12. Please refer to the following link for more information:

    https://www.grapecity.com/spreadnet

    Also, is it possible for you to share the stripped down sample so that I can look into this and share the possible solution in spread6?

    Thanks.

  • Posted 27 May 2019, 7:52 pm EST

    Hello,

    finally I managed to create an example of what I need.

    You´ll find that in the attached zip.

    Also I updated to Spread v12.

    Well, what I wrote in the initial post is still true.

    Additionally:

    The application contains and uses a cell type “IST_TextCellTypeWithSubEditor” derived from TextCellType. This uses the “IST_SubEditorTreeView” (derived from UserControl and ISubEditor) as a sub editor.

    In principle this is working.

    But there are a few issues to solve.

    1. The celltype derives from TextCellType because a combobox celltype didn´t open my custom subeditor.

      But the celltype IST_TextCellTypeWithSubEditor must not be editable. I don´t want the user to change the content directly - how can I define this.

    2)In the subeditor IST_SubEditorTreeView the function SetValue(object value) (who ever is calling this) has as the value not the cell-value but the cell-text. But the whole thing should work similar to a combobox with ItemData - so I would expect the value contains the cell-value and not the text. What can I do here?

    1. Every time the cell value has been changed by code, the subeditor opens not at the first click on the dropdown button of the (activated) cell. It´s req. to click twice to open the subeditor. When the cell content is changed via subeditor it works like expected (open at the first click). Any ideas about that?

    Actually I need a combobox-like celltype (working with ItemData) using/opening a custom subeditor as described.

    Any help about my questions are very welcome.

    TreeView_CellType.zip

  • Posted 28 May 2019, 10:20 pm EST

    Hello,

    I don´t want the user to change the content directly - how can I define this

    You modify the following method so that the user enable to enter the text manually:

    
    public override System.Windows.Forms.Control GetEditorControl(System.Windows.Forms.Control parent, FarPoint.Win.Spread.Appearance appearance, float zoomFactor)
            {
    
    
                GeneralEditor myControl = (GeneralEditor)base.GetEditorControl(parent, appearance, zoomFactor);
                  myControl.ButtonStyle = FarPoint.Win.ButtonStyle.DropDown;
             
                myControl.ReadOnly = true;
                return myControl;
            }
    
    

    so I would expect the value contains the cell-value and not the text. What can I do here?

    When you set the cell value, it binds with the SubEditor automatically. Hence, you can use the cell value property instead of SetValue method of SubEditor. Please explain If I am missing something

    When the cell content is changed via subeditor it works like expected (open at the first click). Any ideas about that?

    You can use the “Flag” to stop the dropdown to be close when the value is set through code

    
     bool flag = true;
       public void SetValue(object value)
            {
                
                    string nodeText = value.ToString();
    
                   
    
                    TreeNode node = _allNodes.FirstOrDefault(element => element.Value.Text == nodeText).Value;
    
                    if (node != null)
                    {
                        trvElements.SelectedNode = node;
    
                    }
    
                flag = !flag;
               
                Debug.WriteLine("----->  SetValue (SubEditor): --- value: " + value);
              
            }
            private void TrvElements_AfterSelect(object sender, TreeViewEventArgs e)
            {
                if (e.Node.Name != "")
                {
                    ValueChanged?.Invoke(this, e);
    
                    if (flag)
                    {
                        CloseUp?.Invoke(this, e);
    
                    }
                    Debug.WriteLine("----->  SetValue (close2): --- value: " + flag);
    
                }
            }
    
    

    Hope it helps.

    Thanks.

  • Posted 29 May 2019, 1:26 am EST

    Hello,

    Ok, that´s a step forward.

    • The tip with that flag works good so far.

    • The tip with that ReadOnly property of the derived textcelltype works partly.

      The active celltype now is readonly. But it contains still a blinking cursor (which cannot be used or even moved). I need this active celltype without that cursor - like a combobox behaves. How can I achieve this?

    • When you set the cell value, it binds with the SubEditor automatically. Hence, you can use the cell value property instead of SetValue method of SubEditor.<<

      Hm, I don´t know what you mean here.

      I my example the cell-value is initially filled by code within the constructor with “itemdata” regler_B. When the spread is displayed it calls automatically the function “Format(object o)” carrying (in “o”) this information to be translated to the cell-text Regler B. This works. But when the cell is activated and the dropdown button is pressed the function “SetValue(object value)” within my subeditor is called (from [external code]) carrying the cell-text and not the cell-value (in “value”). So, do you mean I can ignored this and can use the cell-value directly? But how can I access the cell from my subeditor layer?

  • Posted 30 May 2019, 10:04 pm EST

    Hello

    We are working on this. Will update you soon.

    Thanks.

  • Posted 3 June 2019, 5:59 pm EST

    Hello,

    any progress so far?

  • Posted 4 June 2019, 12:23 am EST

    Hello,

    Sorry for the delay!

    I have escalated the issue to our development team(273082) and will inform you once I have any information from them.

    Thanks,

  • Posted 4 June 2019, 12:43 am EST

    Hello,

    Could you please confirm that you want a custom cell type which works same as ComboBoxCellType but the drop down show custom control (like TreeView) but not standard list control. Is that correct?

    Thanks.

  • Posted 4 June 2019, 4:19 pm EST

    Hello,

    that´s exactly what I need.

  • Posted 5 June 2019, 6:12 pm EST

    Thanks for the information.

  • Posted 9 June 2019, 9:11 pm EST

    Hello,

    Could you please check with the attached sample.

    Thanks.

    customCelltype.zip

  • Posted 11 June 2019, 5:24 pm EST

    Hello,

    yes, this looks better.

    But there are still some issues which should be fixed.

    1. When the cell gets activated it shows the value and not the text.
    2. When the cell gets activated the displayed text is selected/highlighted.
    3. The cell goes in edit mode with a single click (standard in our apps is a double click).

    If you can fix these things too, this would be great.

    Regards.

  • Posted 12 June 2019, 7:45 pm EST

    Hello,

    I made a mistake.

    Point (2) is obsolete. The text of the selected/activated cell should be selected.

    Sorry for that.

    Regards

  • Posted 13 June 2019, 1:48 am EST

    Hello,

    I have forwarded this to our development team and will inform you once I get any reply from them.

    Thanks.

  • Posted 16 June 2019, 10:33 pm EST

    Hello,

    Here is some suggestion for your issues :

    When the cell gets activated it shows the value and not the text.

    you should override the SetEditorValue function of his custom cell type to display text.

    The text of the selected/activated cell should be selected.

    Inside CustomGeneralEditor, there is a ShowList function. You should remove the code which selects text there.

    The cell goes in edit mode with a single click (standard in our apps is a double click).

    Override IsReservedLocation and return null for area which doesn’t trigger editing mode by single-click.

    Hope it helps.

    Thanks.

Need extra support?

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

Learn More

Forum Channels