我正在尝试使用C#和WinForms在Telerik RadGridView GridViewComboBoxColumn
中设置下拉窗口的宽度。但是我只找到了设置整个列的宽度的方法:
foreach (GridViewColumn col in radGridView1.Columns)
{
GridViewComboBoxColumn cbCol = col as GridViewComboBoxColumn;
cbCol.Width = 200;
}
但这不是我想要的。我希望下拉窗口比列本身更宽。我还发现了一个
DropDownStyle
属性:cbCol.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDown;
// or this
cbCol.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList;
但这没有任何区别(至少对我而言没有视觉上的区别),而且我找不到类似
DropDownWidth
之类的属性。 最佳答案
这个给你:
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
radGridView1.CellEditorInitialized += RadGridView1_CellEditorInitialized;
}
private void RadGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
{
RadDropDownListEditor editor = e.ActiveEditor as RadDropDownListEditor;
if (editor != null)
{
RadDropDownListEditorElement ddlElement =(RadDropDownListEditorElement ) editor.EditorElement;
ddlElement.DropDownMinSize = new Size(200, 300);
}
}