Home > Mobile >  How to display list items in gridview?
How to display list items in gridview?

Time:10-18

//This list contains a lot of values

        List<Säljare> säljare = new List<Säljare>();

//sort list

        int[] nivåOrder = { 1, 2, 3, 4 };
        säljare = säljare.OrderBy(x => Array.IndexOf(nivåOrder, x.Nivå)).ToList();

//output list into gridview

        dgvViewsäljare.Rows.Add(säljare);
        dgvViewsäljare.Rows[dgvViewsäljare.Rows.Count - 1].Tag = nySäljare;

/*The output I get is "Systems.Collections.Generic.List[WindowsFormsApp62.form1 Säljare] Why? and how do I fix it? Thanks in advance */

CodePudding user response:

dgvViewsäljare.DataSource = säljare;

CodePudding user response:

 try
{
    if (e == null)
        return;

    if (e.CmsData != null)
    {
        Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)(() =>
        {
            this.datagrid.ItemsSource = e.CmsData.Agents.ToList();
        }));
    }
}

Try this

  •  Tags:  
  • c#
  • Related