MulitColumn ComboBox scrolls when clicking on an item

6 posts, 0 answers
  1. Jason
    Jason avatar
    24 posts
    Member since:
    Apr 2011

    Posted 13 Apr 2011 Link to this post

    When I click on my RadMultiColumnComboBox, the dropdown opens displaying my grid of items. There's about 100 or so items, so the list is scrollable. Occasionally when clicking an item, for some reason the scroll position changes. This is causing a different item to be selected since it looks like an item gets selected when the click releases. So if the grid is displaying items 1 through 5,
    1
    2
    3
    4
    5
    ...
     I'll click on item 3, the scroll position will slightly shift down so now my mouse is over item 4. So by the time the click is released, it selects item 4. Does that make sense? I was wondering if anyone has come across a similar issue before I try extracting code to post.

    Thanks,
    Jason

    I've added code to illustrate the problem. When I click on the item Code = 2, it selects Code = 3.
    Version: 2010.3.10.1215
  2. Jason
    Jason avatar
    24 posts
    Member since:
    Apr 2011

    Posted 13 Apr 2011 Link to this post

    I don't know why, but adding

     rmccbxMyBox.AutoSizeDropDownToBestFit = false;
     rmccbxMyBox.BestFitColumns();

    seems to fix it.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Jason
    Jason avatar
    24 posts
    Member since:
    Apr 2011

    Posted 13 Apr 2011 Link to this post

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using Telerik.WinControls;
    using Telerik.WinControls.Data;
    using Telerik.WinControls.UI;
     
    namespace MulitColumnComboBox
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
     
            }
     
            protected override void OnLoad( EventArgs e )
            {
                SetUpYardMultiColumnComboBox( m_rmcbxYard );
                FillYards( m_rmcbxYard );
                m_rmcbxYard.AutoSizeDropDownToBestFit = true;
            }
     
            public void FillYards( RadMultiColumnComboBox rmcbxYard )
            {
                DataTable dt = new DataTable();
                dt.Columns.Add( new DataColumn( "Id", typeof( Guid ) ) );
                dt.Columns.Add( new DataColumn( "Name", typeof( string ) ) );
                dt.Columns.Add( new DataColumn( "Code", typeof( string ) ) );
     
                for( int i = 0; i < 100; i++ )
                {
                    DataRow dr = dt.NewRow();
     
                    dr[ "Id" ] = Guid.Empty;
                    dr[ "Name" ] = "Name" + " - " + i;
                    dr[ "Code" ] = i;
                    dt.Rows.Add( dr );
                }
     
                rmcbxYard.SuspendLayout();
                rmcbxYard.DataSource = dt;
                rmcbxYard.ResumeLayout();
            }
     
     
            protected void SetUpYardMultiColumnComboBox( RadMultiColumnComboBox rmccbxYard )
            {
                rmccbxYard.AutoFilter = true;
                rmccbxYard.BestFitColumns();
     
                rmccbxYard.DisplayMember = "Code";
                rmccbxYard.ValueMember = "Id";
     
                var objMultiColumnComboBoxElement = rmccbxYard.MultiColumnComboBoxElement;
                objMultiColumnComboBoxElement.Font = new System.Drawing.Font( "Segoe UI", 10F, System.Drawing.FontStyle.Bold );
                objMultiColumnComboBoxElement.DropDownSizingMode = SizingMode.UpDownAndRightBottom;
                objMultiColumnComboBoxElement.EditorControl.MasterTemplate.AutoGenerateColumns = false;
                objMultiColumnComboBoxElement.EditorControl.MasterTemplate.ShowRowHeaderColumn = false;
                objMultiColumnComboBoxElement.EditorControl.MasterTemplate.AllowRowResize = false;
                objMultiColumnComboBoxElement.DropDownWidth = 170;
     
                var objEditorControl = rmccbxYard.MultiColumnComboBoxElement.EditorControl;
                objEditorControl.Font = new System.Drawing.Font( "Segoe UI", 10F, System.Drawing.FontStyle.Bold );
     
                var column = new GridViewTextBoxColumn( "Code" );
                column.HeaderText = "Code";
                objMultiColumnComboBoxElement.Columns.Add( column );
     
                column = new GridViewTextBoxColumn( "Name" );
                column.HeaderText = "Name";
                objMultiColumnComboBoxElement.Columns.Add( column );
     
                column = new GridViewTextBoxColumn( "Id" );
                column.HeaderText = "Id";
                column.IsVisible = false;
                objMultiColumnComboBoxElement.Columns.Add( column );
     
                var objDescriptorCode = new FilterDescriptor( "Code", FilterOperator.StartsWith, string.Empty );
     
                rmccbxYard.EditorControl.FilterDescriptors.Add( objDescriptorCode );
                rmccbxYard.DropDownStyle = RadDropDownStyle.DropDown;
            }
        }
    }
    namespace MulitColumnComboBox
    {
        partial class Form1
        {
            /// <summary>
            /// Required designer variable.
            /// </summary>
            private System.ComponentModel.IContainer components = null;
     
            /// <summary>
            /// Clean up any resources being used.
            /// </summary>
            /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
            protected override void Dispose( bool disposing )
            {
                if( disposing && (components != null) )
                {
                    components.Dispose();
                }
                base.Dispose( disposing );
            }
     
            #region Windows Form Designer generated code
     
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {
                this.m_rmcbxYard = new Telerik.WinControls.UI.RadMultiColumnComboBox();
                ((System.ComponentModel.ISupportInitialize)(this.m_rmcbxYard)).BeginInit();
                ((System.ComponentModel.ISupportInitialize)(this.m_rmcbxYard.EditorControl)).BeginInit();
                ((System.ComponentModel.ISupportInitialize)(this.m_rmcbxYard.EditorControl.MasterTemplate)).BeginInit();
                this.SuspendLayout();
                //
                // m_rmcbxYard
                //
                //
                // m_rmcbxYard.NestedRadGridView
                //
                this.m_rmcbxYard.EditorControl.BackColor = System.Drawing.SystemColors.Window;
                this.m_rmcbxYard.EditorControl.Font = new System.Drawing.Font( "Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)) );
                this.m_rmcbxYard.EditorControl.ForeColor = System.Drawing.SystemColors.ControlText;
                this.m_rmcbxYard.EditorControl.Location = new System.Drawing.Point( 0, 0 );
                //
                //
                //
                this.m_rmcbxYard.EditorControl.MasterTemplate.AllowAddNewRow = false;
                this.m_rmcbxYard.EditorControl.MasterTemplate.AllowCellContextMenu = false;
                this.m_rmcbxYard.EditorControl.MasterTemplate.AllowColumnChooser = false;
                this.m_rmcbxYard.EditorControl.MasterTemplate.EnableGrouping = false;
                this.m_rmcbxYard.EditorControl.MasterTemplate.ShowFilteringRow = false;
                this.m_rmcbxYard.EditorControl.Name = "NestedRadGridView";
                this.m_rmcbxYard.EditorControl.ReadOnly = true;
                this.m_rmcbxYard.EditorControl.ShowGroupPanel = false;
                this.m_rmcbxYard.EditorControl.Size = new System.Drawing.Size( 240, 150 );
                this.m_rmcbxYard.EditorControl.TabIndex = 0;
                this.m_rmcbxYard.Location = new System.Drawing.Point( 90, 113 );
                this.m_rmcbxYard.Name = "m_rmcbxYard";
                //
                //
                //
                this.m_rmcbxYard.RootElement.AutoSizeMode = Telerik.WinControls.RadAutoSizeMode.WrapAroundChildren;
                this.m_rmcbxYard.Size = new System.Drawing.Size( 106, 20 );
                this.m_rmcbxYard.TabIndex = 0;
                this.m_rmcbxYard.TabStop = false;
                this.m_rmcbxYard.Text = "radMultiColumnComboBox1";
                //
                // Form1
                //
                this.AutoScaleDimensions = new System.Drawing.SizeF( 6F, 13F );
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.ClientSize = new System.Drawing.Size( 290, 268 );
                this.Controls.Add( this.m_rmcbxYard );
                this.Name = "Form1";
                this.Text = "Form1";
                ((System.ComponentModel.ISupportInitialize)(this.m_rmcbxYard.EditorControl.MasterTemplate)).EndInit();
                ((System.ComponentModel.ISupportInitialize)(this.m_rmcbxYard.EditorControl)).EndInit();
                ((System.ComponentModel.ISupportInitialize)(this.m_rmcbxYard)).EndInit();
                this.ResumeLayout( false );
                this.PerformLayout();
     
            }
     
            #endregion
     
            private Telerik.WinControls.UI.RadMultiColumnComboBox m_rmcbxYard;
        }
    }
  5. Svett
    Admin
    Svett avatar
    728 posts

    Posted 18 Apr 2011 Link to this post

    Hi Jason,

    This is the known issue, which will addressed in the upcoming service pack. I am glad to hear that you found a work around for it.

    Best wishes,
    Svett
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Jason
    Jason avatar
    24 posts
    Member since:
    Apr 2011

    Posted 26 Apr 2011 Link to this post

    Not to beat a dead horse, but if anyone else needs a work around that simulates the autosizing feature. You can set the drop down width of your box to something really big OnLoad, then handle the _EditorControl_ColumnWidthChanged and _DropDownOpened events to fix the sizing. something like:
    protected void SetUpMultiColumnComboBox()
    {
        m_rmcbxCustomer.AutoSizeDropDownToBestFit = false;
        m_rmcbxCustomer.BestFitColumns();
        m_rmcbxCustomer.MultiColumnComboBoxElement.DropDownWidth = 500;
    }
             
    private void m_rmcbxCustomer_EditorControl_ColumnWidthChanged( object sender, ColumnWidthChangedEventArgs e )
    {
        int newWidth = CalculateWidth( sender );
        m_rmcbxCustomer.MultiColumnComboBoxElement.MultiColumnPopupForm.Width = newWidth;
        m_rmcbxCustomer.MultiColumnComboBoxElement.DropDownWidth = newWidth;
    }
     
    private void m_rmcbxCustomer_DropDownOpened( object sender, EventArgs e )
    {
        m_rmcbxCustomer.MultiColumnComboBoxElement.MultiColumnPopupForm.Width = m_rmcbxCustomer.MultiColumnComboBoxElement.DropDownWidth;
    }
     
    private int CalculateWidth( object sender )
    {
        var objEditorControl = (MasterGridViewTemplate) sender;
        var totalWidth = 0;
        foreach( var col in objEditorControl.Columns )
        {
            if( col.IsVisible )
            {
                totalWidth += col.Width;
            }
        }
        return totalWidth;
    }

  7. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 29 Apr 2011 Link to this post

    Hello Jason,

    Thank you for writing and for sharing your code with the community. 

    Like my colleague Svett declared, this issue was addressed in Q1 2011 SP1. Feel free to download and try the latest release. As usual, your feedback will be appreciated. 

    Here is a link to the PITS item for the issue.

    Should you have any other questions, do not hesitate to contact us.

    Greetings,
    Stefan
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top
UI for WinForms is Visual Studio 2017 Ready