Hi,
I search the forum for a solution on this but without finding any answer on it.
I have a multicolumn dropdownlist in my grid.
I use a customized Editor (found in one of the threads here) to show the data.
But when i click on one row, i want the list to disappear and the value to be set in the cell.
And how can i show only the two last columns ( not the ID field) ?
And how can i remove the header row?
Here is the testcode i use:
I search the forum for a solution on this but without finding any answer on it.
I have a multicolumn dropdownlist in my grid.
I use a customized Editor (found in one of the threads here) to show the data.
But when i click on one row, i want the list to disappear and the value to be set in the cell.
And how can i show only the two last columns ( not the ID field) ?
And how can i remove the header row?
Here is the testcode i use:
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using Telerik.WinControls.UI;namespace TestRadGrid{ public partial class Form1 : Form { List<RowHelper> rows = new List<RowHelper>(); public Form1() { InitializeComponent(); Telerik.WinControls.UI.GridViewDecimalColumn gridViewDecimalColumn1 = new Telerik.WinControls.UI.GridViewDecimalColumn(); Telerik.WinControls.UI.GridViewTextBoxColumn gridViewTextBoxColumn1 = new Telerik.WinControls.UI.GridViewTextBoxColumn(); Telerik.WinControls.UI.GridViewComboBoxColumn gridViewComboBoxColumn1 = new Telerik.WinControls.UI.GridViewComboBoxColumn(); Telerik.WinControls.UI.GridViewMultiComboBoxColumn gridViewComboBoxColumn2 = new Telerik.WinControls.UI.GridViewMultiComboBoxColumn(); rows.Add(new RowHelper(1, "Row1", 1)); rows.Add(new RowHelper(2, "Row2", 2)); rows.Add(new RowHelper(3, "Row3", 3)); rows.Add(new RowHelper(4, "Row4", 1)); List<helper> list = new List<helper>(); list.Add(new helper(1, "test1")); list.Add(new helper(2, "test2")); list.Add(new helper(3, "test3")); List<multicolumnhelper> multicolumnlist = new List<multicolumnhelper>(); multicolumnlist.Add(new multicolumnhelper(1, "test1","col2")); multicolumnlist.Add(new multicolumnhelper(2, "test2", "col2")); multicolumnlist.Add(new multicolumnhelper(3, "test3", "col2")); gridViewComboBoxColumn1.DataSource = list; gridViewComboBoxColumn1.DisplayMember = "Value"; gridViewComboBoxColumn1.ValueMember = "ID"; gridViewComboBoxColumn1.HeaderText = "Test"; gridViewComboBoxColumn1.Name = "test"; gridViewComboBoxColumn1.FieldName = "RowID"; gridViewTextBoxColumn1.Name ="rowtext"; gridViewTextBoxColumn1.HeaderText ="rowtext"; gridViewTextBoxColumn1.FieldName = "RowText"; gridViewComboBoxColumn2.DataSource = multicolumnlist; gridViewComboBoxColumn2.DisplayMember = "Value"; gridViewComboBoxColumn2.ValueMember = "ID"; gridViewComboBoxColumn2.HeaderText = "Test"; gridViewComboBoxColumn2.Name = "test2"; gridViewComboBoxColumn2.FieldName = "RowID"; radGridView1.Columns.AddRange(new Telerik.WinControls.UI.GridViewDataColumn[] {gridViewComboBoxColumn1, gridViewTextBoxColumn1, gridViewComboBoxColumn2}); PopulateData(); } private void radGridView1_CellBeginEdit(object sender, GridViewCellCancelEventArgs e) { } private void PopulateData() { radGridView1.DataSource = rows; } private void radGridView1_EditorRequired(object sender, EditorRequiredEventArgs e) { if (e.EditorType == typeof(RadMultiColumnComboBoxElement)) { MyRadMultiColumnComboBoxElement editor = new MyRadMultiColumnComboBoxElement(); e.Editor = editor; } } } public class helper { public helper(int id, string value) { ID = id; Value = value; } public int ID { get; set; } public string Value { get; set; } } public class multicolumnhelper { public multicolumnhelper(int id, string value, string value2) { ID = id; Value = value; Value2 = value2; } public int ID { get; set; } public string Value { get; set; } public string Value2 { get; set; } } public class RowHelper { public RowHelper(int id, string text, int id2) { RowID = id; RowText = text; RowID2 = id2; } public int RowID { get; set; } public string RowText { get; set; } public int RowID2 { get; set; } } public class MyRadMultiColumnComboBoxElement : RadMultiColumnComboBoxElement { public MyRadMultiColumnComboBoxElement() { this.DropDownWidth = 200; } protected override RadPopupControlBase CreatePopupForm() { RadPopupControlBase popup = new MyMultiColumnComboPopupForm(this); return popup; } protected override Type ThemeEffectiveType { get { return typeof(RadComboBoxElement); } } } public class MyMultiColumnComboPopupForm : MultiColumnComboPopupForm { public MyMultiColumnComboPopupForm(PopupEditorBaseElement owner) : base(owner) { } public override string ThemeClassName { get { return typeof(MultiColumnComboPopupForm).FullName; } set { } } public override void ShowPopup(Rectangle alignmentRectangle) { int delta = alignmentRectangle.Width - this.Size.Width; if (delta > 0) { alignmentRectangle.X += delta; alignmentRectangle.Width -= delta; } base.ShowPopup(alignmentRectangle); } }}