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

ComboBox - autocompletemode and sorting problem

2 Answers 197 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Robert Stuczynski
Top achievements
Rank 1
Robert Stuczynski asked on 18 Feb 2010, 02:55 PM
I add ComboBox column to GidView using this code:

GridViewComboBoxColumn stockCode = new GridViewComboBoxColumn();  
      stockCode.DataSource = dbS.view_Trans_Order_StockCodes;  
      stockCode.DisplayMember = "StockCode";  
      stockCode.ValueMember = "StockCode";  
      stockCode.FieldName = "StockCode";  
      stockCode.AutoCompleteMode = AutoCompleteMode.Suggest;  
      radGridView1.MasterGridViewTemplate.Columns.Add(stockCode); 

Data is displayed in GridView by I need:
- sort it. It is possible in this ComboBox? I try use like in normla ComboBox but it is not work
- using autocompletemode. I try do it but it is not working as Suggested :( I do now why

Could you help me?

2 Answers, 1 is accepted

Sort by
0
Accepted
Svett
Telerik team
answered on 19 Feb 2010, 08:41 AM
Hi Robert Stuczynski,

If you are using GridViewComboBoxColumn with AutoCompleteMode.Suggest, you need to set DropDownStyle property to RadDropDownStyle.DropDown -- the combo box column doesn't sort its data source. In the meantime, you can sort your data source before binding it to the column. If you are using a DataTable as data source, you can use the following code snippet to sort your records:

GridViewComboBoxColumn cbColumn = new GridViewComboBoxColumn("ComboBoxColumn", "ComboBoxColumn");
cbColumn.ValueMember = "Value";
cbColumn.DisplayMember = "Name";
 
// Sorting your data table by Name Column
dataTable.DefaultView.Sort = "Name ASC";
cbColumn.DataSource = dt.DefaultView;
 
cbColumn.AutoCompleteMode = AutoCompleteMode.Suggest;
cbColumn.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDown;
this.radGridView.Columns.Add(cbColumn);

Do not hesitate to contact us back if you need further assistance.

All the best,
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.
0
Robert Stuczynski
Top achievements
Rank 1
answered on 19 Feb 2010, 09:20 AM
AutoComplete work! Thanks

Thanks for tip about sorting. I use it:

stockCode.DataSource = dbS.view_Trans_Order_StockCodes.OrderBy(o => o.StockCode); 
Tags
GridView
Asked by
Robert Stuczynski
Top achievements
Rank 1
Answers by
Svett
Telerik team
Robert Stuczynski
Top achievements
Rank 1
Share this question
or