I am trying to add two columns with ultra-combo boxes to Ultra grid. So far I have this code , but I don’t see the column. Why is that.
UltraGridLayout layout = args.Layout;
UltraGridBand band = layout.Bands[0];
band.Columns["Cutsomer"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
This should help.
HOWTO:What is the best way to place a DropDown list in a grid cell?
Let me know if you still have trouble getting it to work or any questions. :)
Thank you
I tried the version with the value list, I did everithing like in the example. But I dont see even the added column in my grid.
What I am doing wrong
This is my code, it doesnt eror out but the column is not added to the grid
private void grdValidShipTo_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { // ** Place Event Handling Code Here ** grdValidShipTo.DisplayLayout.Bands[0].Columns.Add("NewColumn", "NewColumn"); grdValidShipTo.DisplayLayout.Bands[0].Columns["NewColumn"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; grdValidShipTo.DisplayLayout.Bands[0].Columns["NewColumn"].ValueList = createFirstValueList(); } private ValueList createFirstValueList() { ValueList vl1 = new ValueList( ); vl1.ValueListItems.Add( 1, "True" ); vl1.ValueListItems.Add( 2, "False" ); return vl1; }
I also tried this ,without success.
I am aslo calling bindUltraDropDown() in load event
private void grdValidShipTo_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { // ** Place Event Handling Code Here ** e.Layout.Bands[0].Columns["Int32 1"].ValueList = ultraDropDown1; } private void bindUltraDropDown() { DataTable dt = new DataTable(); dt.Columns.Add("ID", typeof(int)); dt.Columns.Add("DisplayText", typeof(string)); dt.Rows.Add(new object[] {1, "A"}); dt.Rows.Add(new object[] {2, "B"}); dt.Rows.Add(new object[] {3, "C"}); dt.AcceptChanges(); UltraDropDown ultraDropDown1 = new UltraDropDown(); ultraDropDown1.SetDataBinding(dt, null); ultraDropDown1.ValueMember = "ID"; ultraDropDown1.DisplayMember = "DisplayText";
}
Well, I don't see anything wrong with your code that's adding the column. My best guess is that something is happening after this code is executed which is removing the column. Maybe you are calling grid.DisplayLayout.Load and blowing away these settings.
If that's not the case, maybe you can post a small sample project demonstrating the problem, and I'd be happy to tell you why it's not working.
I figured out how to achieve the combo box
Now I have problem displaying two fields in the combo box
I want to display CustID and Name and the value will be only CustID
foreach(DataRow listRow in dsListCustomer.Tables[0].Rows)
{ valueList.ValueListItems.Add(listRow["CustID"].ToString(), listRow["Name"].ToString());
Please could you paste the code as I have arrived at a similar problem and would like to see what you have done to make the combox work