Home Forums WinForms controls Xceed Grid for WinForms Creating an ComboxEditor

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

    I have this code for creating an combobox editor

     

    public class ComboBoxInfo

    {

    private string _Desc = string.Empty;

    private string _Description = string.Empty;

    private object _Tag;

    private int _Value;

    }

     

    List

    <ComboBoxInfo> valuelist= null;
    if (_ValueList != null && _ValueList.ContainsKey(pRMSettingTypeSetting.Key)){
    _ValueList.TryGetValue(pRMSettingTypeSetting.Key,
    out valuelist);
    if (valuelist != null){
    ComboBoxEditor autoCompletingComboBoxEditor = new ComboBoxEditor(valuelist, “Value”, “Description”);
    autoCompletingComboBoxEditor.TemplateControl.SearchMode = SearchMode.FullText;
    pCellEditorManager = autoCompletingComboBoxEditor;
    pCellViewerManager =
    new ComboBoxViewer(valuelist, “Value”, “Description”);

    }}

     

    In the Rich Cell Editors example u can only use a dataset, but i want to use a List<>.

    Can someone help me?

     

    Imported from legacy forums. Posted by Insider (had 3095 views)

    User (Old forums)
    Member
    Post count: 23064

    I don’t know what is the <ComboBoxinfo>, but if it is a class with at least Value and Description properties, then the problem is how you bind the ComboBoxEditor.

    Instead of :

    ComboBoxEditor autoCompletingComboBoxEditor = new ComboBoxEditor( valuelist, “Value”, “Description” );

    Do like the following :

    ComboBoxEditor autoCompletingComboBoxEditor = new ComboBoxEditor( valuelist, “”, “Value”, “%Description%” );

     

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

    User (Old forums)
    Member
    Post count: 23064

    i always get the following error

     

    {Xceed.Grid.GridInternalException}
     HelpLink:   
     InnerException:  
     Message:   Impossible to bind the grid to the specified data source and member.
     Source:   Xceed.Grid
     TargetSite.Name:  BindToDataSource
     TargetSite.MemberType: Method
     StackTrace:     bij Xceed.Grid.DataManager.BindToDataSource(Object dataSource, String dataMember, Boolean onlyWhenNotSameList, Boolean& dataChanged)
       bij Xceed.Grid.DataManager.ForceDataBinding(Object dataSource, String dataMember, Boolean onlyWhenNotSameList, Boolean createDataRows)
       bij Xceed.Grid.DataManager.SetDataBinding(Object dataSource, String dataMember)
       bij Xceed.Grid.DetailGrid.SetDataBinding(Object dataSource, String dataMember)
       bij Xceed.Grid.GridControl.SetDataBinding(Object dataSource, String dataMember)
       bij Xceed.Editors.WinComboBox.SetDataBinding(Object dataSource, String dataMember)
       bij Xceed.Editors.WinComboBox..ctor(Type callerType, EnhancedBorderStyle borderStyle, Object dataSource, String dataMember, String valueMember)
       bij Xceed.Grid.Editors.ComboBoxEditor..ctor(Object dataSource, String dataMember, String valueMember)
       bij Compufit.ResourceManagement.OptionsForm.setEditType(Cell pCell, RMSettingTypeSettingInfo pRMSettingTypeSetting, CellEditorManager& pCellEditorManager, CellViewerManager& pCellViewerManager) in C:\SourceCode\Oxygen\trunk\Compufit ResourceManagement\Compufit.ResourceManagement\OptionsForm.cs:regel 2679
       bij Compufit.ResourceManagement.OptionsForm.setEditTypes(DataRow pDataRow, RMSettingTypeSettingInfo pRMSettingTypeSetting) in C:\SourceCode\Oxygen\trunk\Compufit ResourceManagement\Compufit.ResourceManagement\OptionsForm.cs:regel 2448
       bij Compufit.ResourceManagement.OptionsForm.fillSettingsGrid() in C:\SourceCode\Oxygen\trunk\Compufit ResourceManagement\Compufit.ResourceManagement\OptionsForm.cs:regel 1130
       bij Compufit.ResourceManagement.OptionsForm.tab_SelectedTabChanged(Object sender, TabEventArgs e) in C:\SourceCode\Oxygen\trunk\Compufit ResourceManagement\Compufit.ResourceManagement\OptionsForm.cs:regel 773
       bij Janus.Windows.UI.Tab.UITab.OnSelectedTabChanged(TabEventArgs e)
       bij Janus.Windows.UI.Tab.UITab.set_SelectedTab(UITabPage value)
       bij Janus.Windows.UI.Tab.UITab.OnMouseDown(MouseEventArgs e)
       bij System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
       bij System.Windows.Forms.Control.WndProc(Message& m)
       bij System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       bij System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       bij System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       bij System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       bij System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       bij System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       bij System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       bij System.Windows.Forms.Application.Run(Form mainForm)
       bij Test.Start.Main(String[] args) in C:\SourceCode\Oxygen\trunk\Compufit ResourceManagement\Test\Start.cs:regel 51

    Imported from legacy forums. Posted by Insider (had 491 views)

    User (Old forums)
    Member
    Post count: 23064

    Now i use an own control instead of the ComboBoxEditor.

    Code:

    CFComboBox

    comboBox = new CFComboBox();

    //comboBox.AutoSize = true;

    //comboBox.Dock = DockStyle.Fill;

    comboBox.DataSource = valuelist;

    comboBox.DisplayMember =

    “Description”;

    comboBox.ValueMember =

    “Value”;

    pCellEditorManager =

    new CellEditorManager(comboBox, “SelectedValue”, true, true);

    pCellViewerManager =

    new CellViewerManager(comboBox, “SelectedValue”);

    Now the list is visible and filled in, the correct data is also preselected.
    But when i change the data, the change doesnt stick, it just returns to the orginal value.

    Example

    Valuelist:
    Value (int)                Description(string)
    1                       Car1
    2                       Car2
    3                       Car3

    The preselected value is 2 => in the combobox the text “Car2” is selected. When I change the value through the list from “Car2” to “Car3”, the cell stays on “Car2”

    Imported from legacy forums. Posted by Insider (had 803 views)

    User (Old forums)
    Member
    Post count: 23064

    There is probably an exception occurring that is swallowed by the grid or the .NET framework.  Is the debugger set to break on all exceptions? (Debug Menu -> Exceptions -> Common Language Runtime Exception, then select select the “Thrown” CheckBox).

    Verify the “Enable Just My Code” CheckBox is unselected (Tools Menu -> Options -> Debugging -> General).

    This will make sure that no exceptions are swallowed by the grid or the framework, and that the debugger will break in any part of the code, not just yours.

    I have also made a small sample that works fine here when binding to a List<>, based on a class containing 2 properties (Value and Description).  Here is the code :

        private static List<CustomComboBoxItem> list;

        private static List<CustomComboBoxItem> list;

        private void Form1_Load( object sender, EventArgs e )
        {
          list = new List<CustomComboBoxItem>();

          for( int i = 0; i < 10; i++ )
          {
            list.Add( new CustomComboBoxItem( i, “item number ” + i.ToString() ) );
          }

          ComboBoxEditor editor = new ComboBoxEditor( list, “”, “Value”, “%Description%” );
          gridControl1.Columns[ 0 ].CellEditorManager = editor;
          ComboBoxViewer viewer = new ComboBoxViewer( list, “”, “Value”, “%Description%” );
          gridControl1.Columns[ 0 ].CellViewerManager = viewer;
        }

      public class CustomComboBoxItem
      {
        private int m_Value;
        private string m_Description;

        public CustomComboBoxItem( int value, string description )
        {
          m_Value = value;
          m_Description = description;
        }

        public int Value
        {
          get { return m_Value; }
          set { m_Value = value; }
        }

        public string Description
        {
          get { return m_Description; }
          set { m_Description = value; }
        }
      }

    I suggest you try it, and then compare it to your own project to try to identify the differences, and hopefully the problem.  I have attached a sample project using this code to the post.

     

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

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