c# winform 怎么能在Form1的界面中用控件绑定显示如下效果
姓名 姓名 姓名 姓名 张三 李流 东丈 小三李四 网吧 希望 李名王五 事宜 保存 修改
名字都是从数据库中提取出来的,不要用label 和textbox 这样如果我的数据多的话,就很麻烦,求哥哥姐姐们给个思路,我的初步设想是用DataList的但是Winform没有这个控件,
姓名 姓名 姓名 姓名 张三 李流 东丈 小三李四 网吧 希望 李名王五 事宜 保存 修改
名字都是从数据库中提取出来的,不要用label 和textbox 这样如果我的数据多的话,就很麻烦,求哥哥姐姐们给个思路,我的初步设想是用DataList的但是Winform没有这个控件,
解决方案 »
- 怎么能生成实时更新的数据库脚本?
- 提交试题代码。始终不能判断选择题,判断题没有错。原因在哪里?
- C# 写入文件把内存占光了,怎么解决呀,以下是代码
- winfrom中的MonthCalendar 是否有類似web中的DayRender事件
- 高难提交问题,无法提交
- win98运行.NET程序需要的条件是什么??这个问题我以前在论坛看到过,现在找不到了~!
- 求解事件的具体构造和调用步骤
- 水晶报表问题
- 关于ASP.NET结合C#操作SQL应用服务等例子
- 如何把Form1中点击Button 的消息交给 Form2处理,
- datagridview 计算列动态变化
- Help!TcpClient怎么在短时间之内(比如5秒钟)循环发送10000条数据?
{
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);
}
}
/// 在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());
}
}
}//以上两个方法都可以
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
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