Home Forums WinForms controls Xceed Grid for WinForms ComboBoxEditor AutocompleteMode and Null Value

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #14900 |

    Hello,

    I would like to know if it is possible to get the ComboBoxEditor (bounded to a table on SQLServer) in a cell of a GridControl to allow null value as a selected value.

    Also is there a way to set AutoCompleteMode=SuggestAppend like the Dotnet ComboBox? I tried setting it in DataBoundColumn->CellEditorManager->TemplateControl->TextBoxArea->AutoComplete but the designer always reset it to “None”.

    Thank you!
    Sylvain Menard

    Imported from legacy forums. Posted by menardsy (had 2767 views)

    User (Old forums)
    Member
    Post count: 23064

    You should be able to handle null values. If you still have an issue, please send me your code and I will try to see what’s wrong.

    Xceed WinComboBox does not support autocomplete. This was decided since the framework combobox supports it.

    Imported from legacy forums. Posted by Matt (had 2917 views)

    User (Old forums)
    Member
    Post count: 23064

    I also want to have autocomplete functionality in my ComboBoxEditor. I think your answer means that I could derive or wrap the standard .NET ComboBox to use it as an editor, but I haven’t been able to figure out how to do this. Can you provide more specific examples of how to get a grid cell’s editor to act like a dropdown combobox with autocomplete?

    Imported from legacy forums. Posted by AlphaGuys (had 469 views)

    User (Old forums)
    Member
    Post count: 23064

    Yes you can extend the CellEditorManager and CellViewerManager classes to extend the grid’s functionality.  Here is more information on how to do this from our help documentation :

    http://doc.xceedsoft.com/products/XceedGrid/CellViewerManager_and_CellEditorManager_extensions.html

    http://doc.xceedsoft.com/products/XceedGrid/Deriving_from_the_CellEditorManager_class.html

    Basically, you need to create a control, and wrap it around a CellEditorManager, like this :

    ComboBox comboBox = new ComboBox();

    gridControl1.Columns[ “ComboColumn” ].CellEditorManager = new CellEditorManager( comboBox, “SelectedItem”, true, true );

     

    Imported from legacy forums. Posted by André (had 357 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks, that gets me most of the way there, but I still don’t quite “get” cell editing.

    Using this suggested code, I can set various properties of the Windows’ ComboBox control, such as

                    comboBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend;

    I also want to be able to respond to the ComboBox’s SelectionChangeCommitted event. When the event handler fires for this, the ComboBox control is passed in as the sender, which allows me to determine which value the user selected in the ComboBox. But I can’t figure out how to tell which cell is being edited. Is there some way to determine which cell the current cell editor is in?

    I had tried an alternate method, where I set the Activating/DeactivatingControl event handler of the CellEditorManager, but these events allow me to specify an action only when the edit control’s text is changed AND THEN it loses focus. This is a very awkward user interface; I really want the code to respond when the user selects/changes a value in the combo box and not have to wait until the user clicks on some other screen object. Am I missing something here?

    Imported from legacy forums. Posted by AlphaGuys (had 441 views)

    User (Old forums)
    Member
    Post count: 23064

    You still need to use the ActivatingControl/DeactivatingControl events. This is necessary because the editor is actually initialized only when the cell receives focus, and enters the edit mode.  Then you subscribe to the ComboBox events in the ActivatingControl event handler.  The following code shows how to do this, you only need to cast your editor to the .NET ComboBox instead of the WinComboBox in the event handlers.

    e.g.:

    //at Form_Load

        private void Form1_Load(object sender, System.EventArgs e)
        {
          gridControl1.Columns[ “column6” ].CellEditorManager.ActivatingControl += new CellEditorEventHandler(CellEditorColumn6_ActivatingControl);
          gridControl1.Columns[ “column6” ].CellEditorManager.DeactivatingControl += new CellEditorEventHandler(CellEditorColumn6_DeactivatingControl);
        }

    //Event handlers

        private void CellEditorColumn6_ActivatingControl(object sender, CellEditorEventArgs e)
        {
          ( ( WinComboBox )e.Control).SelectedIndexChanged += new EventHandler(ComboBoxColumn6_SelectedIndexChanged);
        }

        private void CellEditorColumn6_DeactivatingControl(object sender, CellEditorEventArgs e)
        {
          //need to unsubscribe to the event, so it does not keep piling up in the ActivatingControl
          ( ( WinComboBox )e.Control).SelectedIndexChanged -= new EventHandler(ComboBoxColumn6_SelectedIndexChanged);
        }

        private void ComboBoxColumn6_SelectedIndexChanged(object sender, EventArgs e)
        {
          string index = “index ” + ( ( WinComboBox )sender).SelectedIndex.ToString();
          System.Diagnostics.Debug.WriteLine( index );
        }

    Imported from legacy forums. Posted by André (had 1306 views)

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.