Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2490
UltraDropDown with UltraWinGrid
posted

Hi,

Now I use Entityframework and when I get my object is return object "Province" not "Province_Id"

The problem I Have is when I put UltraDropDown in UltraWinGrid is need the value "Province_Id" but is not the Id have is full "Province" entity

Do you have solution to replace "Id" value to entity "Province" ? or peak ValueMembre to Province.Id ?

uddAddressMaillingProvince.DataSource = new BusinessLogicClass().GetAll();
uddAddressMaillingProvince.DisplayMember = "Name";
uddAddressMaillingProvince.ValueMember = "Id";

 var col = ugrdAddressMailling.DisplayLayout.Bands[0].Columns["Province"];

col.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownValidate ;
col.ValueList = uddAddressMaillingProvince;

I build Partial class, is work

I 'd like to know if there is a solution without creating another property

 

public int Province_Id
{
get { return Province.Id; }

set { }
}

Francois.

  • 469350
    Verified Answer
    Offline posted

    Hi Francois,

    If I understand correctly, what you want is that when the user selects an item from the UltraDropDown, the grid cell is updated with the underlying data object for the entire dropdown row

    The UltraDropDown doesn't really work that way, but you can achieve this with a little clever coding. Normally, only one field of the selected row in the dropdown is assigned to the value of the grid cell. So what you would need to do is have a cell in the dropdown that contains the value you want.

    So what you can do is add an unbound column to the UltraDropDown.

    Set the column's DataType to the same type as the grid cell: 'Province'

    In the InitializeRow event of the UltraDropDown, you populate the cell in this unbound column with the Province object for the row. You get this using the row's ListObject. 

    Then you can use this unbound column as the ValueMember for the UltraDropDown.

    The code would look something like this:

            uddAddressMaillingProvince.ValueMember = "Province";


            private void uddAddressMaillingProvince_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
            {
                var band = e.Layout.Bands[0];

                if (false == band.Columns.Exists("Province"))
                {
                    var column = band.Columns.Add("Province");
                    column.DataType = typeof(Province);
                    column.Hidden = true;
                }
            }

            private void uddAddressMaillingProvince_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
            {
                if (e.Row.Cells.Exists("Province"))
                    e.Row.Cells["Province"].Value = (Province)e.Row.ListObject;
            }