7 Answers, 1 is accepted
0
Emanuel Varga
Top achievements
Rank 1
answered on 19 Jan 2011, 09:18 AM
Hello Somnath,
Just use the CellEditorInitialized event and use MaxDropDownItems to set the maximum number of items to display in the dropdown.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
Just use the CellEditorInitialized event and use MaxDropDownItems to set the maximum number of items to display in the dropdown.
void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e){ var editor = e.ActiveEditor as RadDropDownListEditor; if (editor == null) { return; } var editorElement = editor.EditorElement as RadDropDownListEditorElement; editorElement.MaxDropDownItems = 4;}Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
0
Somnath
Top achievements
Rank 1
answered on 19 Jan 2011, 11:14 AM
Hi Emanuel,
Thanks for your support....
But this code does not give any kind of change in my application.....
I am waiting for your responce..
Thanks,
Thanks for your support....
But this code does not give any kind of change in my application.....
I am waiting for your responce..
Thanks,
0
Emanuel Varga
Top achievements
Rank 1
answered on 19 Jan 2011, 11:17 AM
Hello again Somnath,
Please take a look at the following example:
Please try using the newer property DefaultItemsCountInDropDown, i found that in some cases the value of the MaxDropDownItems is being overwritten by this one.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
Please take a look at the following example:
using System;using System.Collections.Generic;using System.Windows.Forms;using Telerik.WinControls.UI;public partial class Form1 : Form{ private RadGridView radGridView1; public Form1() { InitializeComponent(); this.Controls.Add(radGridView1 = new RadGridView()); radGridView1.Dock = DockStyle.Fill; radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; radGridView1.CellEditorInitialized += new GridViewCellEventHandler(radGridView1_CellEditorInitialized); radGridView1.DataSource = new List<Test> { new Test(1, "Name1"), new Test(2, "Name2") }; var column = new GridViewComboBoxColumn("TestCombo"); column.DataSource = new List<string> { "Name1", "Name2", "Name3", "Name4", "Name5", "Name6", "Name7" }; radGridView1.Columns.Add(column); } void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e) { var editor = e.ActiveEditor as RadDropDownListEditor; if (editor == null) { return; } var editorElement = editor.EditorElement as RadDropDownListEditorElement; //you can use either //editorElement.MaxDropDownItems = 6; //or the newer property editorElement.DefaultItemsCountInDropDown = 6; }}public class Test{ public int Id { get; set; } public string Name { get; set; } public Test(int id, string name) { this.Id = id; this.Name = name; }}Please try using the newer property DefaultItemsCountInDropDown, i found that in some cases the value of the MaxDropDownItems is being overwritten by this one.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
0
Richard Slade
Top achievements
Rank 2
answered on 19 Jan 2011, 11:22 AM
Hi Guys,
If you need to change the size of the drop down then you could use the following inside the CellEditorInitialized
Hope that helps
Richard
If you need to change the size of the drop down then you could use the following inside the CellEditorInitialized
var editor = e.ActiveEditor as RadDropDownListEditor; if (editor == null) { return; } var editorElement = editor.EditorElement as RadDropDownListEditorElement; editorElement.DropDownMinSize = new Size(0,300);Hope that helps
Richard
0
Somnath
Top achievements
Rank 1
answered on 19 Jan 2011, 11:57 AM
Hello Emanuel,
Thanks for reply,
editorElement.DefaultItemsCountInDropDown = 6;
Yours code working here, since I want itms list up to 25
Thanks for reply,
editorElement.DefaultItemsCountInDropDown = 6;
Yours code working here, since I want itms list up to 25
but problem is that DefaultItemsCountInDropDown property
does not take more than 8 items..
Thanks
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 19 Jan 2011, 12:04 PM
Hello,
There are two properties that manage the number of items in drop down portion of the RadDropDownList.
If number of items is greater than DefaultItemsCountInDropDown, it restricts the number of items to DefaultItemsCountInDropDown.
The second property MaxDropDownItems is used for backward compability with the old RadComboBox and also restricts the number of items to MaxDropDownItems. DefaultItemsCountInDropDown cannot be greater than the MaxDropDownItems.
Please refer to the code snippet below which demonstrates how RadDropDownList calculates the number of items:
As DefaultItemsCountInDropDown cannot be greater than MaxDropDownItems you also need to check/set that property in this case.
Hope that helps
Richard
There are two properties that manage the number of items in drop down portion of the RadDropDownList.
If number of items is greater than DefaultItemsCountInDropDown, it restricts the number of items to DefaultItemsCountInDropDown.
The second property MaxDropDownItems is used for backward compability with the old RadComboBox and also restricts the number of items to MaxDropDownItems. DefaultItemsCountInDropDown cannot be greater than the MaxDropDownItems.
Please refer to the code snippet below which demonstrates how RadDropDownList calculates the number of items:
int itemsCount = this.listElement.Items.Count; if (itemsCount > defaultItemsCountInDropDown || itemsCount == 0){ itemsCount = defaultItemsCountInDropDown;}if (itemsCount > this.maxDropDownItems){ itemsCount = this.maxDropDownItems;}As DefaultItemsCountInDropDown cannot be greater than MaxDropDownItems you also need to check/set that property in this case.
Hope that helps
Richard
0
Somnath
Top achievements
Rank 1
answered on 19 Jan 2011, 12:15 PM
Hello Richard,
Thanks... This code help me to solve my problem...
Thanks... This code help me to solve my problem...