Windows表格中Datagrid的安排 [英] Arrangement in Datagrid in Windows forms

查看:80
本文介绍了Windows表格中Datagrid的安排的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在处理包含两列和25行的datagrid,我需要按
的顺序排列数据 1. col1,col2
中显示的前十行 2.新列中的下十行(如rdlc报告中的列)

请问有人可以指导我实现这一目标吗?

Hi,

I am working on datagrid which contains two columns with 25 rows, I need to arrange the data in the order as
1.First ten rows shown in the col1,col2
2.Next ten rows in new columns(like columns in rdlc reports)

Kindly can anyone guide me to achieve this...

推荐答案

我认为您可以使用LINQ来做到这一点:

StudentsDataContext db = new StudentsDataContex();
var tblStudents =(从db.tStudents中的行开始).OrderBy(p => p.col1).ThenBy(p => p.col2);

datagridview.datasource = tbl学生;

希望这对您有所帮助.
I think you could do it with LINQ like this:

StudentsDataContext db=new StudentsDataContex();
var tblStudents= (from row in db.tStudents).OrderBy(p=>p.col1).ThenBy(p=>p.col2);

datagridview.datasource=tblStudents;

Wish this helps you.


这篇关于Windows表格中Datagrid的安排的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆