Good evening folks, I'm new here and I hope someone can give me some extra insight into my current situation.I'll try and be as complete and to the point as possible in describing my situation.Basically I have a Windows Form UltraWinGrid which I'm populating with List<T>, however, I wish to replace several id-fields by their respective description fields.Let's scetch my situation with a simple example.Say I have a List<Customer> and the Customer class includes the usual properties like name, first name, birth date, ...But also various id fields. The Customer class is a object that gets it's data filled from OR mapping from a persistent storage medium, in my case that's a SQLServer2005 database, the id fields are basically the relationship fields from the database. Basically Customer object is pretty much an object representation of the persistent table.So for example:public class Customer{ String name, firstName, PhoneNumber, ... int customerId, favColorId, livingPlaceId}public class FavoriteColors{ int favColorId string colorName, hexNotation, string RGBNotation}public class LivingPlace{ int livingPlaceId string country, city, countryCode, postalCode}So I have a List<Customer> customers and bind it to my grid in code behind as 'customersGrid.Datasource = customers'This works fine and my whole system has already been programmed around working like this. So for functionality there's no problem. After all, it's the id values that are used for the programmatic identifying and so on.However like this I display values to the user that he wouldn't really understand as the first record would for example be CustId Name FirstName Phone FavColorId LivingPlaceId1 Me Me Again 2211 1 1So when displaying the grid I would like FavColorId to be replaced with it's colorName with that Id. The same for livingPlace, I'd want the grid to show country for example with that stored id.For this example let's assume the values are stored in a List<FavoriteColors> and a List<LivingPlace>.That's what I'm seeking to accomplish in a nutshell. I was thinking of adding an unbound column for each id-field (in code) after setting the datasource to customers (haven't looked it up yet, but that should be possible right?), and afterward I'd go through the whole grid with a foreach(UltraGridRow in grid) loop, filling the unbound columns with the looked-up data.And then I'd hide the columns that the user doesn't actually need to see.However, I suppose that'll be rather performance ineffective, so was wondering what you folks think of this.Ok, I think that's about it.
Hi,
This is a very common scenario and it's very easily handled. What you want to do here is use the ValueList property of the column in the grid to attach a list of data and display values to the column. The grid will take care of the rest - translating the data value into a user-friendly display value for the user to see while still keeping the data value in memory and saving it to the data source.
There are two kinds of ValueLists you can use. One is the ValueList class and the other is the UltraDropDown. This KB article will give you more information about how to set it up and which one is right for you:
HOWTO:What is the best way to place a DropDown list in a grid cell?
Mike,
Hmmmm. Any other ideas.
Your suggested method doesn't appear to be working for me. Something must not be right, but Ican't tell what it is because Infragistics Control logic is not throwing an exception.
Regards,Rob
Hi Rib,
What Mike sugested is the best way, another way is to put in your Form an ultraCombo , fill it and add it to the EditorControl property of the Desired Column, insite the InitializeLayout Event of the grid:
e.Layout.Bands[0].Columns["DesiredColumn"].EditorControl = myCombo;
Mike's suggestion :
e.Layout.Bands[0].Columns["DesiredColumn"].ValueList = myValueList;
PS. the valueList is lightweight compare to the ultraCombo so quicker to initialize.
Hope that helped.
Nassos
Nassos,
Thank you for your response,
Yes, I understand the use of a ValueList, and it is what I am after. I have no desire to put a combo, dropdown, or any edit control within a grid at the moment. As it is such a challenge just to get the grid to display the data properly, I shall leave editing out of it.
R.