为什么我在DataGridView中获得未排序的列?

时间:2017-08-24 22:38:39

标签: c# c#-4.0 datagridview

DataGridView是从DataTable填充的:

DataTable dt = new DataTable();

dt = serviceSqlite.select();

dataGridView1.DataSource = dt;

select方法在SELECT中包含以下字段序列:

                "Pacients.id, " +
                "unique_code," +
                "status_pass, " +
                "payment, " +
                "profession," +
                "office_address, " +
                "factory_name, " +
                "factory_edrpou, " +
                "factory_departament," +
                "name, " +
                "secondname, " +
                "lastname, " +
                "datebirth, " +
                "taxcode, " +
                "gender, " +
                "Pacients.created_at, " +
                "PacientsOrder.kind_work, " +
                "PacientsOrder.status "

同样在DataTable的属性中,我移动列名如下:

enter image description here

为什么我在程序启动时在DataGridView中获取未排序的列?列的顺序不是我在属性中设置的。

1 个答案:

答案 0 :(得分:0)

{68F5E655-2E2D-492E-B445-BE1650AF5FAE}列使用 Observable.fromFuture(it).onErrorResumeNext(Observable.empty()) ,以特定顺序显示列。

在将SetOrdinal绑定到DataTable之前,请执行此操作。

例如:

DataTable

将其绑定到DataGridView后,当您运行该应用程序时,您可以看到列显示为名称,国家/地区,大陆,地点。