DataGridView的使用水平列 [英] DataGridView with horizontal columns

查看:125
本文介绍了DataGridView的使用水平列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能在DataGridView的水平列,结合这些列的能力?

Is it possible to have a horizontal columns in DataGridView, with ability to bind those columns?

推荐答案

您不要有翻转DataGridView的代替翻转绑定

You dont have to Flip the DataGridView instead Flip the DataSet to bind

试试这个:

public DataSet FlipDataSet(DataSet my_DataSet)
{
 DataSet ds = new DataSet();

 foreach (DataTable dt in my_DataSet.Tables)
 {
   DataTable table = new DataTable();

   for (int i = 0; i <= dt.Rows.Count; i++)
   {   table.Columns.Add(Convert.ToString(i));  }

   DataRow r;
   for (int k = 0; k < dt.Columns.Count; k++)
   { 
     r = table.NewRow();
     r[0] = dt.Columns[k].ToString();
     for (int j = 1; j <= dt.Rows.Count; j++)
     {  r[j] = dt.Rows[j - 1][k]; }
     table.Rows.Add(r);
   }
   ds.Tables.Add(table);
 }

 return ds;
}

有关更多详情,请访问的显示-立式行,在DataGrid中,视图

For more details visit Displaying-Vertical-Rows-in-DataGrid-View

这篇关于DataGridView的使用水平列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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