c# winform 怎么能在Form1的界面中用控件绑定显示如下效果
姓名   姓名    姓名   姓名  张三   李流    东丈   小三李四   网吧    希望   李名王五   事宜    保存    修改
名字都是从数据库中提取出来的,不要用label 和textbox 这样如果我的数据多的话,就很麻烦,求哥哥姐姐们给个思路,我的初步设想是用DataList的但是Winform没有这个控件,

解决方案 »

  1.   

    用DataGridView或者ListView控件。
      

  2.   

    如果我的表结构是id name的话,DataGirdView要怎么搞
      

  3.   

    就是把名字列出来吗?那listview就行啊
      

  4.   

    只是显示的话,可以用GDI+画的方式啊,也很容易(网上教程很多)才几行代码你把所有文字读到一string变量中用空格和回车符来分隔,richtextbox控件显示也行啊
      

  5.   

    http://heisetoufa.javaeye.com/blog/227748
      

  6.   

    DataGridView
      

  7.   

    public static void DisplayDataSet(ListView listView, DataSet dataSet, bool includeNo)
      {
      if(dataSet == null)
      {
      return;
      }
      listView.Items.Clear();
      DataTable dataTable = dataSet.Tables[0];
      int rowno = 0;
      ListViewItem item;
      foreach(DataRow dataRow in dataTable.Rows)
      {   
      item = new ListViewItem();
      rowno++;
      if(includeNo)
      {
      item.Text = rowno.ToString();
      }
      for (int i = 0; i < dataTable.Columns.Count; i++)
      {
      string str = dataRow[i].ToString();
      item.SubItems.Add(dataRow[i].ToString());
      }
      listView.Items.Add(item);
      }
      }
      

  8.   

              /**//// <summary>
              /// 在ListView 控件中显示 DataTable的数据;
              /// </summary> 
            public static void DataInListView(DataTable dt, ListView lst)
            {
                lst.Clear();
                lst.View = View.Details;
                //   lst.View=System.Windows.Forms.View.Details;
                lst.AllowColumnReorder = true;//用户可以调整列的位置
                lst.GridLines = true;            int RowCount, ColCount, i, j;
                DataRow dr = null;            if (dt == null) return;
                RowCount = dt.Rows.Count;
                ColCount = dt.Columns.Count;
                //添加列标题名
                for (i = 0; i < ColCount; i++)
                {
                    lst.Columns.Add(dt.Columns[i].Caption.Trim(), lst.Width / ColCount, HorizontalAlignment.Left);
                }            if (RowCount == 0) return;
                for (i = 0; i < RowCount; i++)
                {
                    dr = dt.Rows[i];
                    lst.Items.Add(dr[0].ToString().Trim());
                    for (j = 1; j < ColCount; j++)
                    {
                        lst.Items[i].SubItems.Add((string)dr[j].ToString().Trim());
                    }
                }
            }//以上两个方法都可以
      

  9.   

    if  OBJECT_ID('test') is not null  drop table test
    Go
    create table test(

    indextage int identity(1,1),
    ID varchar(6),
    Name varchar(10)
    )
    GO
    insert into test
    select '0001','AAAAA' union all
    select '0002','BBBBB' union all
    select '0003','CCCCC' union all
    select '0004','DDDDD' union all
    select '0005','EEEEE' union all
    select '0006','FFFFF' union all
    select '0007','GGGGG' union all
    select '0008','HHHHH' union all
    select '0009','FFFFF' union all
    select '00010','GGGGG' union all
    select '00011','HHHHH' union all
    select '00012','FFFFF' union all
    select '00013','GGGGG' union all
    select '00014','HHHHH' union all
    select '00015','FFFFF' union all
    select '00016','GGGGG' union all
    select '00017','HHHHH'
    --GOselect 
     a.ID as ID1
    ,a.Name as Name1
    ,b.ID as ID2
    ,b.Name as Name2
    ,c.ID as ID3
    ,c.Name as Name3
    ,d.ID as ID4
    ,d.Name as Name4
    ,e.ID as ID5
    ,e.Name as Name5
    ,f.ID as ID6
    ,f.Name as Name6from 
    test a left join test b on a.indextage % 6=1 and b.indextage %6=2 and a.indextage<b.indextage
    LEFT join  test c on  c.indextage %6=3 and b.indextage<c.indextage
    LEFT join test d on  d.indextage %6=4 and c.indextage<d.indextage
    LEFT join  test e on e.indextage %6=5 and d.indextage<e.indextage
    LEFT join test f on  f.indextage %6=0 and e.indextage<f.indextage
    where    (a.indextage<b.indextage or b.Name is null)
     and (b.indextage<c.indextage or c.Name is null)
     and (c.indextage<d.indextage or d.Name is null)
     and (d.indextage<e.indextage or e.Name is null)
     and (e.indextage< f.indextage or f.Name is null)
     and (a.indextage % 6=1)
     and (b.indextage-a.indextage<2 or b.Name is null)
     and (c.indextage-b.indextage<2 or c.Name is null)
     and (d.indextage-c.indextage<2or d.Name is null)
     and (e.indextage-d.indextage<2 or e.Name is null)
     and (f.indextage-e.indextage<2 or f.Name is null)
     
    order by  a.indextage 
      

  10.   


    if  OBJECT_ID('test') is not null  drop table test
    Go
    create table test(

    indextage int identity(0,1),
    ID varchar(6),
    Name varchar(10)
    )
    GO
    insert into test
    select '0001','AAAAA' union all
    select '0002','BBBBB' union all
    select '0003','CCCCC' union all
    select '0004','DDDDD' union all
    select '0005','EEEEE' union all
    select '0006','FFFFF' union all
    select '0007','GGGGG' union all
    select '0008','HHHHH' union all
    select '0009','FFFFF' union all
    select '00010','GGGGG' union all
    select '00011','HHHHH' union all
    select '00012','FFFFF' union all
    select '00013','GGGGG' union all
    select '00014','HHHHH' union all
    select '00015','FFFFF' union all
    select '00016','GGGGG' union all
    select '00017','HHHHH' union all
    select '00018','GGGGG' union all
    select '00019','HHHHH' union all
    select '00020','FFFFF' union all
    select '00021','GGGGG' union all
    select '00022','HHHHH'GO
    with cteA as
    (
    select 
    case when a.indextage % 6=0 then a.ID  end as ID0
    ,case when a.indextage % 6=0 then a.Name end as Name0
    ,case when a.indextage % 6=1 then  a.ID  end as ID1
    ,case when a.indextage % 6=1 then a.Name end as Name1
    ,case when a.indextage % 6=2 then a.ID end as ID2
    ,case when a.indextage % 6=2 then a.Name end as Name2
    ,case when a.indextage % 6=3 then a.ID end as ID3
    ,case when a.indextage % 6=3 then a.Name end as Name3
    ,case when a.indextage % 6=4 then a.ID  end as ID4
    ,case when a.indextage % 6=4 then a.Name end as Name4
    ,case when a.indextage % 6=5 then a.ID end as ID5
    ,case when a.indextage % 6=5 then a.Name  end as Name5    ,case when a.indextage % 6=5 
         then  floor(ROW_NUMBER()over(order by a.indextage)/6)-1 
          else floor(ROW_NUMBER()over(order by a.indextage)/6) end  as GroupTag
    from test as a
    )--select * from cteA
    ,cteB as
    (
    select
    MAX(ID0) as  ID6
       ,MAX(Name0) as Name6   
       ,MAX(ID1) as ID1
       ,MAX(Name1)  as Name1
       ,MAX(ID2) as ID2
       ,MAX(Name2) as Name2
       ,MAX(ID3) as ID3
       ,MAX(Name3) as Name3
       ,MAX(ID4) as ID4
       ,MAX(Name4) as Name4
       ,MAX(ID5) as ID5
       ,MAX(Name5) as Name5
    from cteA
    group by GroupTag
    )select * from cteB