I'm using static BindingList as DataSource:
public class Items{ public static DateTime FechaTrabajo = DateTime.Today; public static MyBindingList<Pedidos> pedidos = new MyBindingList<Pedidos>(); public static async Task Load(DateTime fechaTrabajo) { try { pedidos.Clear(); FechaTrabajo = fechaTrabajo; pedidos.Add(await SSEService.Instance.GetPedidos(fechaTrabajo)); pedidos.ListUpdated(); } catch (Exception) { } }}
Where MyBindingList extends BindingList and ListUpdated is like:
public void ListUpdated(){ this.OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, 0));}
I'm using Items.pedidos as datasource for the Grid and all is working perfect, grid is updating data when needed, but when I need selectedrows, if Items.pedidos has had data and now is empty. When I call:
private void bNuevoPalet_Click(object sender, EventArgs e){ int rows = this.radGridView1.Rows.Count; int srows = this.radGridView1.SelectedRows.Count; if (this.radGridView1.SelectedRows.Count > 0) { Pedidos ped = this.radGridView1.SelectedRows[0].DataBoundItem as Pedidos; if (ped != null) { fPedido.ShowMe(ped); } }}
rows = 0
but srows = 1
