Well, I had the next experience, in DataGridView, i set the datasource before the display member, but when I set the display member, the grid took so time like I set the DataSource... so I did the test, and I set first the displaymember and after the datasource, and the time load decrease to the half, then I think with the ListBox was the same
using System;
using System.Collections.Generic;
using System.Text;
namespace Entidades.Administracion
{
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public class OrganizacionBE
{
private int _intIDOrganizacion;
private string _strNombre;
private string _strDireccion;
private string _strDescripcion;
private bool _bolEstatus;
#region Metodos Get y Set
public bool Estatus
{
get { return _bolEstatus; }
set { _bolEstatus = value; }
}
public string Descripcion
{
get { return _strDescripcion; }
set { _strDescripcion = value; }
}
public string Direccion
{
get { return _strDireccion; }
set { _strDireccion = value; }
}
public string Nombre
{
get { return _strNombre; }
set { _strNombre = value; }
}
public int IDOrganizacion
{
get { return _intIDOrganizacion; }
set { _intIDOrganizacion = value; }
}
#endregion
public OrganizacionBE(int pIntIDOrganizacion, string pStrNombre, string pStrDireccion, string pStrDescripcion) {
_intIDOrganizacion = pIntIDOrganizacion;
_strNombre = pStrNombre;
_strDireccion = pStrDireccion;
_strDescripcion = pStrDescripcion;
}
}
}
And I fill my ListBox with a Collection inherit CollectionBase, here my code
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
namespace Entidades.Administracion
{
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public class OrganizacionBECollection : CollectionBase
{
private static string _strValueField = "IDOrganizacion";
private static string _strTextField = "Nombre";
public static string ValueField
{
get { return OrganizacionBECollection._strValueField; }
}
public static string TextField
{
get { return OrganizacionBECollection._strTextField; }
}
public int Add(OrganizacionBE value)
{
return (List.Add(value));
}
public void Add(int idx, OrganizacionBE value)
{
List.Insert(idx, value);
}
public OrganizacionBE this[int index]
{
get { return ((OrganizacionBE)List[index]); }
set { List[index] = value; }
}
public void Remove(OrganizacionBE pEntidad)
{
List.Remove(pEntidad);
}
public OrganizacionBE Find(OrganizacionBE pEntidad)
{
return this[List.IndexOf(pEntidad)];
}
public OrganizacionBE Find(int pId)
{
IEnumerator IE = List.GetEnumerator();
while (IE.MoveNext()) //Recorre la Coleccion con el Enumerador....
{
if (((OrganizacionBE)IE.Current).IDOrganizacion == pId)
return (OrganizacionBE)IE.Current;
}
return null;
}
public void Remove(int intIDOrganizacion)
{
OrganizacionBE obj = this.Find(intIDOrganizacion);
if (obj != null)
this.Remove(obj);
}
}
}
Well, my code to fill the ListBox...
this.lisOrganizaciones.ValueMember = OrganizacionBECollection.ValueField;
this.lisOrganizaciones.DisplayMember = OrganizacionBECollection.TextField;
this.lisOrganizaciones.DataSource = _colOrganizaciones;
And so my problem is here... I try this...
this.lisOrganizaciones.DataSource = null;
this.lisOrganizaciones.DisplayMember = OrganizacionBECollection.TextField;
this.lisOrganizaciones.DataSource = _colOrganizaciones;
And here, I should do that you say..., Could you show me the reflection of DisplayMember?, or Could you say me how can i do it?
Thanks a lot