I have a radMultiColumnComboBox1 which resizes the contents of its dropdown grid perfectly the first time its DataSource is set. It doesn’t resize itself, however, upon subsequent assignments to its DataSource.
This is illustrated by the two attachments. In “DataSourceSetForFirstTime.png,” everything looks great. In “DataSourceSetTheSecondTime.png,” however, the grid retains its original width even though the data no longer necessitates it.
The code I have is shown below. (As the commented out portions suggests, I’ve tried a number of things.) Can you please help me get the grid to resize itself whenever its DataSource changes?
radMultiColumnComboBox1.AutoFilter = true;
radMultiColumnComboBox1.EditorControl.MasterTemplate.ShowRowHeaderColumn = false;
RadGridView gridViewControl = this.radMultiColumnComboBox1.EditorControl;
gridViewControl.MasterTemplate.AutoGenerateColumns = false;
gridViewControl.Columns.Clear();
//Specify the columns which the dropdown should show
for (int i = 0; i < lookupDescription.fields.Count(); i++)
gridViewControl.Columns.Add(new GridViewTextBoxColumn(lookupDescription.fields[i]));
//Set the suggestions
radMultiColumnComboBox1.DataSource = suggestions;
//Tweak the width. http://www.telerik.com/help/winforms/gridview-columns-resizing-columns-programatically.html
radMultiColumnComboBox1.AutoSizeDropDownToBestFit = true;
radMultiColumnComboBox1.BestFitColumns(true, true);
//gridViewControl.AutoSize = true; //This breaks things
//gridViewControl.AllowAutoSizeColumns = true; //This has no visible affect
radMultiColumnComboBox1.MultiColumnComboBoxElement.TextBoxElement.Text = comboText.curVal;
radMultiColumnComboBox1.MultiColumnComboBoxElement.ShowPopup();
radMultiColumnComboBox1.EditorControl.Update();
radMultiColumnComboBox1.EditorControl.BestFitColumns(BestFitColumnMode.AllCells);
/*
radMultiColumnComboBox1.DropDownSizingMode = SizingMode.UpDownAndRightBottom;
radMultiColumnComboBox1.MultiColumnComboBoxElement.ResetLayout(true);
radMultiColumnComboBox1.MultiColumnComboBoxElement.UpdateLayout(); */
//radMultiColumnComboBox1.MultiColumnComboBoxElement.EditorControl.AutoSizeColumnsMode=GridViewAutoSizeColumnsMode.Fill;
Thank you,
Ben