[英]Reorder GridView Columns (filled from database)
I have this method using webservice to connect my desktop app to a oracle database: 我有使用Web服务将我的桌面应用程序连接到oracle数据库的方法:
public List<Persona> ListaPersona()
{
List<Persona> personas = new List<Persona>();
Persona persona;
Conexion con = new Conexion();
OracleCommand cmd = con.OracleConexion().CreateCommand();
cmd.CommandText = "select * from persona";
DataSet ds = new DataSet();
OracleDataAdapter adapter = new OracleDataAdapter(cmd);
adapter.Fill(ds);
foreach (DataRow fila in ds.Tables[0].Rows)
{
persona = new Persona();
persona.IdPersona = Int32.Parse(fila["IDPERSONA"].ToString());
persona.Rut = Int32.Parse(fila["RUT"].ToString());
persona.DigiVeri = fila["DIGIVERI"].ToString();
persona.Nombre = fila["NOMBRES"].ToString();
persona.ApPaterno = fila["APPATERNO"].ToString();
persona.ApMaterno = fila["APMATERNO"].ToString();
persona.Edad = Int32.Parse(fila["EDAD"].ToString());
persona.FechaNacimiento = fila["FECHA_NACIMIENTO"].ToString();
persona.Genero = fila["GENERO"].ToString();
persona.Correo = fila["CORREO"].ToString();
persona.Telefono = Int32.Parse(fila["TELEFONO"].ToString());
persona.Direccion = fila["DIRECCION"].ToString();
persona.Comuna = Int32.Parse(fila["COMUNA"].ToString());
persona.Contrasena = fila["CONTRASENA"].ToString();
persona.Empresa = Int32.Parse(fila["EMPRESA"].ToString());
persona.Cargo = Int32.Parse(fila["CARGO"].ToString());
persona.Activo = Int32.Parse(fila["ACTIVO"].ToString());
persona.Expositor = Int32.Parse(fila["EXPOSITOR"].ToString());
persona.Personal = Int32.Parse(fila["PERSONAL"].ToString());
persona.FechaIngreso = fila["FECHA_INGRESO"].ToString();
personas.Add(persona);
}
return personas;
}
It returns the list of all the users registered on the system, and i show them on a gridview. 它返回在系统上注册的所有用户的列表,我将它们显示在gridview上。 It display the data perfect, but in some random order i don't know why, so i wan't to reorder the colums of the gridview. 它显示了完美的数据,但是我不知道为什么以某种随机顺序排列,所以我不想对gridview的列进行重新排序。
This is the windowsform load code: 这是Windowsform的加载代码:
public testLista()
{
InitializeComponent();
WebService.ServicioClient s = new WebService.ServicioClient();
dataGridView1.DataSource = s.ListaPersona().ToList();
}
You can map it manually. 您可以手动映射。 On your DataGridView, you will see a triangle to the top right bottom. 在DataGridView上,您将在右上角底部看到一个三角形。 There you can map it manually according to the order you like. 您可以在那里按照自己喜欢的顺序手动进行映射。 (Sorry, I coouldn't comment since I need 50 reputation, I only have 11) (对不起,我无法发表评论,因为我需要50个信誉,我只有11个信誉)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.