需要在c#中创建表格格式(windows应用程序) [英] Need to Create a table format in c# (windows Application)
问题描述
Hi Everybady,
我想在c#中创建一个表。但请仔细阅读我的问题。
我在MSsql中有2列表格
column1- as CustomerId
column2 as Drawtime
在C#Windows Applcation中,我从此表中获得完整的数据。
我的DataTable中的数据显示如下。
CustomerId | DrawTime
1 09:00
2 09:15
3 09:30
现在我想使用c#在Form上显示这样的
| 1 | 09:00 | 2 | 09:15 | 3 | 09:30 | 4 | 09:45 | 5 | 10:00 |
| 6 | 10:15 | 7 | 10:30 | 8 | 10:45 | 9 | 11:00 | 10 | 11:15 |
谁在这样的表格中显示记录。请帮我指导
我。
我不明白如何显示这样的记录。
我正在使用datagridview但是在这个控件中是不可能的。
谢谢
Ram Kumar
Hi Everybady,
I want to create a table in c#. But Please read my problem carefully.
I have table in MSsql with 2 column
column1- as CustomerId
column2 as Drawtime
In C# Windows Applcation i get the complete data from this table.
My Data in DataTable display like this.
CustomerId | DrawTime
1 09:00
2 09:15
3 09:30
Now I want to display on Form using c# like this
|1 | 09:00 | 2 | 09:15 | 3 | 09:30 | 4 | 09:45 | 5 | 10:00 |
|6 | 10:15 | 7 | 10:30 | 8 | 10:45 | 9 | 11:00 | 10 | 11:15 |
Who to display record in table like this. Please help me guide
me.
I do not understand how to display record like this.
I am using datagridview but it is not possible in this control.
thanks
Ram Kumar
推荐答案
另一种方法是使用System.Windows.Forms.ListView将View属性更改为SmallIcon。
格式化表格结果并将其添加到列表视图中,例如
Another alternative is to use a System.Windows.Forms.ListView changing the View property to SmallIcon.
Format your table results and add them to the listview e.g.
this.listView1.Items.Add(new ListViewItem(Text = string.Format("|{0}|{1}", CustomerId, DrawTime)));
为控件选择合适的宽度,以便显示5个图标
Choose an appropriate width for the control so that 5 "icons" are displayed
您应该使用DataList控件以行方式显示记录 -
参考 -
http://msdn.microsoft.com/en-us/library/bb525467.aspx
You should use DataList control to display records as row wise-
Refer -
http://msdn.microsoft.com/en-us/library/bb525467.aspx
我想到了一个可能的解决方案,遍历数据表,每组5个(CustomerID / DrawTable)对创建一行..虽然逻辑有点粗糙(相当标准的原则,将线性'索引'或计数转换为下标[row,column]对)
你想让我发帖更多吗? (或者你找到了答案?)
I thought of a possible solution iterating through your datatable, every group of 5 (CustomerID/DrawTable) pairs creates one row.. the logic's a bit rough though (fairly standard principle, convert an linear 'index' or count to a subscript [row, column] pair)
Do you want me to post more ? (or have you found an answer ?)
这篇关于需要在c#中创建表格格式(windows应用程序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!