I am trying to figure out how to add a valuelist to the ultragrid but everything I've found and tried has not worked. I have to be missing something. If someone could step me through each step for just a simple list of a couple of items, I could figure out the rest from there.
Thanks,Kevin
The code below creates ValueList and ValueListItems and adds them to the grid.
ValueList is a list of items that you can attach to your UltraGridColumnsValueList valueList1 = new ValueList(38170917);ValueListItem valueListItem1 = new ValueListItem();ValueListItem valueListItem2 = new ValueListItem();ValueListItem valueListItem3 = new ValueListItem();ValueListItem valueListItem4 = new ValueListItem();ValueList valueList2 = new ValueList(46896754);ValueList valueList3 = new ValueList(46906719);
valueList1.DisplayStyle = Infragistics.Win.ValueListDisplayStyle.DisplayText; valueList1.Key = "Type"; valueListItem1.DataValue = "Attending Physician"; valueListItem1.DisplayText = "Attending Physician"; valueListItem2.DataValue = "Assistant"; valueListItem2.DisplayText = "Assistant"; valueListItem3.DataValue = "Technician"; valueListItem3.DisplayText = "Technician"; valueListItem4.DataValue = "Procedurist"; valueListItem4.DisplayText = "Procedurist"; valueList1.ValueListItems.Add(valueListItem1); valueList1.ValueListItems.Add(valueListItem2); valueList1.ValueListItems.Add(valueListItem3); valueList1.ValueListItems.Add(valueListItem4);valueList2.Key = "Provider"; valueList2.MaxDropDownItems = 15; valueList2.SortStyle = Infragistics.Win.ValueListSortStyle.Ascending; valueList3.Key = "Service"; valueList3.MaxDropDownItems = 15; valueList3.SortStyle = Infragistics.Win.ValueListSortStyle.Ascending; this.grdClinicians.DisplayLayout.ValueLists.AddRange(new Infragistics.Win.ValueList[] { valueList1, valueList2, valueList3});
You can find more information on this link
http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=7841
That was it, I wasn't binding it to anything.
Have you bound the grid to any data? My code works under the assumption that you've already filled the grid with info by binding it to something. Even if you want an empty grid with the ability to add rows, you'll need to bind it to something that represents the data you want your users to add, then turn on the AllowAddNew, AllowUpdate, and CellClickAction properties (all 3 are off of the Override object under DisplayLayout). For instance, the following code:
AllowAddNew = Infragistics.Win.UltraWinGrid.AllowAddNew.FixedAddRowOnBottomAllowUpdate = Infragistics.Win.DefaultableBoolean.TrueCellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.Edit
will turn on a fixed row for adding new data, allow the users to edit grid cells, and put cells into edit mode when a user clicks on it.
Pretty much, yeah.
But I'm using VB.Net to do this so I modified your code above to look like this:
Dim vl As New Infragistics.Win.ValueList()
Dim i As Integer
For i = 1 To 10
vl.ValueListItems.Add(i)
Next i
UltGrd.DisplayLayout.Bands(0).Columns(1).ValueList = vlUltGrd.DisplayLayout.Bands(0).Columns(1).Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList
I have this in the form load section of my code but it's not showing anything when I run the project, just a blank ultra grid. What am I missing?
Thanks,
Kevin
Are you just trying to create a dropdown list in one of the columns in the grid? If that's the case, then here's a small snippet that might help:
-------------------Infragistics.Win.ValueList vl = new Infragistics.Win.ValueList();for (int i = 1; i <= 10; i++){ vl.ValueListItems.Add(i);}
this.ultraGrid1.DisplayLayout.Bands[0].Columns[0].ValueList = vl;this.ultraGrid1.DisplayLayout.Bands[0].Columns[0].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;----------------
All this does is create a simple valuelist, adds 10 items to it, associates it with the first column in the top level (band 0) of the grid and sets the style of the column to be a DropDownList. There's also a BindableValueList object in case you just want to bind to a source of data instead of building up the ValueList by hand.