ComboBox - Return Distinct Values

I have a ComboBox I am binding to a table field that contains a number of rows but is comprised of a only a handful of actual values in the field, how do a limit the list in my ComboBox to the handful of values?

Try using a BAQ Combo box and set the BAQ return to distinct

Thanks, that’s the solution I recalled but wanted to check if someone had an alternative. As a followup, I have another field from the same table to bind to another ComboBox. If I call both fields in the same BAQ, I get a value in the ComboBox for each combination of the two fields in the results of the BAQ, i.e. duplications of the values but not to the original frequency. Is there a way to only return the distinct values for each field besides creating a BAQ for each field?

Sorry I don’t follow what you’re asking.

Distinct Values from Column:
One thing to think about would be to add some custom code on the event that populates the list

Non-Duplicate Values in Multiple Columns:
Think about utilizing a Dictionary to add/remove values from as the combo boxes are changed. This will naturally throw exceptions if the same key/value are attempted to be added, thus providing a mechanism to require unique values across multiple columns

Let me try with some visual aids to help explain. The first image shows the distinct data for first field. The second image shows how the list now returns multiple entries for ShortChar01 when ShortChar02 is added to the BAQ and that if ShortChar02 is the other field I will get multiple entries for it as well. I had reviewed the Post in your link before posting but when I tried it in my code, it said that ‘Distinct’ was not recognized by Infragistics. A copy of the code for one of the fields is listed below for your reference. I am not sure the Dictionary is the way to go but I am not familiar with it. The thought I was trying to share was to have a BAQ to return ShortChar01 and another to return ShortChar02 so I got my distinct values.

	_epiUltraGridPltComm.DisplayLayout.Bands[0].Columns["ShortChar01"].ValueList = baqComboRelPlant;_

_ epiUltraGridPltComm.DisplayLayout.Bands[0].Columns[“ShortChar01”].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;_
_ baqComboRelPlant.ForceRefreshList();_

image image

If I understand correctly, you want to take the output of the BAQ and assign the distinct values of ShortChar01 to a combo box and the distinct values of ShortChar02 to another combo box? So you would have [CHINO, CONTDROP, HAWTHORN, JONESBOR, STJOSEPH] showing in one and [Pack, PickList, SalesOrder, Invoice, Pro Forma] showing in the other?

I think you’ll have to do it manually with a Dynamic Query Adapter and then set the DataSource for an UltraCombo to the distinct list of values.

using (DynamicQueryAdapter dqa = new DynamicQueryAdapter(oTrans))
	Ice.BO.QueryExecutionDataSet ds = new Ice.BO.QueryExecutionDataSet();
	dqa.ExecuteByID("myBAQ", ds);
	epiUltraComboC1.DataSource = dqa.QueryResults.Tables["Results"].AsEnumerable().Select(s => s.Field<string>("ShortChar01")).Distinct().ToList();
	epiUltraComboC2.DataSource = dqa.QueryResults.Tables["Results"].AsEnumerable().Select(s => s.Field<string>("ShortChar02")).Distinct().ToList();