.Net Links

Tuesday, October 20, 2009

Creating a ComboBox Column in DevExpress Grid and Populating it

Craeting a simple ComboBoxColumn in a grid and populating the combo box from Jan..Dec...

{
GridViewDataComboBoxColumn gridCbxMonth = new GridViewDataComboBoxColumn();
gridCbxMonth.Caption = "Month";
gridCbxMonth.FieldName = "Month";
gridCbxMonth.PropertiesComboBox.DropDownStyle = DropDownStyle.DropDown;
gridCbxMonth.PropertiesComboBox.Width = Unit.Pixel(90);
PopulateMonth(gridCbxMonth);
grid.Columns.Add(gridCbxMonth);
}
private void PopulateMonth(GridViewDataComboBoxColumn Month)
{
DateTime dt = new DateTime();

Month.Items.Add("ALL");
for (int i = 0; i < 12; i++)
{
Month.Items.Add(dt.AddMonths(i).ToString("MMMM"));
}
Month.SelectedIndex = 0;
}

Labels: , , , , , , ,