This is a migrated thread and some comments may be shown as answers.

multicolumnCombobox change columns name

1 Answer 78 Views
ComboBox and ListBox (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
koray
Top achievements
Rank 2
koray asked on 31 Jan 2011, 05:35 PM

i m using this method.maybe helpfull some new developers like me.
public void changeyourcolumnsname()
{string conn="Data Source=yourdatasource; User Id=youruserid; Password=yourpassword; Initial Catalog =yourdataname;";

 

 

 

 

 

using

 

 

(SqlConnection connection = new SqlConnection(conn))

 

{

connection.Open();

 

 

 

 

 

DataSet ds = new DataSet();

 

 

 

 

 

SqlDataAdapter adp = new SqlDataAdapter("select col1,col2,col3,col4 from yourtable",connection);
adp.Fill(ds, "yourtable");

 

 

 

 

 

this.radMultiColumnComboBox1.DataSource = ds.Tables[0];

 

 

 

 

FilterDescriptor descriptor =

 

 

 

new FilterDescriptor(this.radMultiColumnComboBox1.DisplayMember, FilterOperator.StartsWith, string.Empty);

 

 

 

 

 

this.radMultiColumnComboBox1.EditorControl.FilterDescriptors.Add(descriptor);

 

 

 

 

 

this.radMultiColumnComboBox1.DropDownStyle = RadDropDownStyle.DropDown;

 

 

 

 

 

this.radMultiColumnComboBox1.EditorControl.Columns[0].HeaderText = "mycolumns1";//change your col1

 

 

 

 

 

this.radMultiColumnComboBox1.EditorControl.Columns[1].HeaderText = "mycolumns2";//change your col2

 

 

 

 

 

this.radMultiColumnComboBox1.EditorControl.Columns[2].HeaderText = "mycolumns3";//change your col3

 

 

 

 

 

this.radMultiColumnComboBox1.EditorControl.Columns[3].HeaderText = "mycolumns4";//change your col4

 

 

 

 

 

 

connection.Close();

 

}

 

private

 

 

 

 

void yourform_Load(object sender, EventArgs e)

 

{

 

 

 

this.radMultiColumnComboBox1.AutoSizeDropDownToBestFit = true;

 

RadMultiColumnComboBoxElement multiColumnComboElement =

 

this.radMultiColumnComboBox1.MultiColumnComboBoxElement;

 

multiColumnComboElement.DropDownSizingMode = SizingMode.UpDownAndRightBottom;

multiColumnComboElement.DropDownMinSize =

 

new Size(420, 300);

 

multiColumnComboElement.EditorControl.MasterGridViewTemplate.AutoGenerateColumns =

 

false;

 

 

 

 

this.radMultiColumnComboBox1.AutoFilter = true;

 

 

 


changeyourcolumnsname();

}

 

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Svett
Telerik team
answered on 03 Feb 2011, 01:12 PM
Hello koray,

Thank you for the supplied code snippet. I suppose our community will find it useful.

Best wishes,

Svett
the Telerik team

 

Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
Tags
ComboBox and ListBox (obsolete as of Q2 2010)
Asked by
koray
Top achievements
Rank 2
Answers by
Svett
Telerik team
Share this question
or