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
Hi,
I'm not sure what you mean. What "added column" are you referring to? There's nothing in the code you posted here that would add a column to the grid. To do that, you use the band.Columns.Add method. All you have here is code that sets the Style on a column to DropDownList, but doesn't actually provide a list to the column.
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
If you want to access the value of a grid cell, then you use the Value property of the grid cell, not the combo. The combo services the entire column, so using the value of the combo would not work.
Thank you I figured out my error. :)
Now I have truble accessing the combo box value inside the grid .
If I tried to access it in the conventional way by combo.Value it is erroring out.
Is there any special way to access it?
Well, that error message is a syntax error in your code and since you didn't provide the code, I can't tell you what's wrong with it.
I figured out how to do that. Now I am trying to filter one of the boxes by the other. I was using cell change event and the event fires in the required time but it gives me the error
The event 'System.Windows.Forms.Control.Layout' can only appear on the left hand side of += or -=