困惑:TableRowCollection [英] Confusion: TableRowCollection

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

问题描述

大家好,


我只是在我的基类中创建一些方法,其中一个返回一个

水平线,在页面上格式化as * I *想要它..基本上是一个

三个表行的集合。


我今晚发现了TableRowCollection,所以我希望我

可以返回其中一个对象,其中包含我的三行,然后

将该集合分配给表格...类似......


Dim Table as Table


Table.Rows.Add(CreateHorizo​​ntalLine())

私有函数CreateHorizo​​ntalLine()As TableRowCollection


Dim TableRowCollection as TableRowCollection


....


返回TableRowCollection


结束功能


不幸的是 - 这似乎没有用 - 我误解了使用

这个对象还是某人请指导我正确的方向...


我可以当然只需返回一个表并将其添加到

表中的一行单元格中,但这样做有点不必要(也许)嵌套...


任何帮助表示赞赏。


问候


Rob

Hi all,

I am just making a few methods in my base class, one of which returns a
horizontal line, formatted on the page as *I* want it..its basically a
collection of three table rows.

I discovered the TableRowCollection this evening, so I was hoping that I
could return one of these objects with my three rows inside it, and then
assign the collection to the table...something like...

Dim Table as Table

Table.Rows.Add(CreateHorizontalLine())
Private Function CreateHorizontalLine() As TableRowCollection

Dim TableRowCollection as TableRowCollection

....

Return TableRowCollection

End Function

Unfortunately - this doesn''t seem to work - have I misinterpreted the use of
this object or can someone guide me in the right direction please...

I could of course just return a table and add that to a cell in a row in the
table, but this does kinda make unnecessary (maybe) nesting...

Any help appreciated.

Regards

Rob

推荐答案

Rob,


Table.Rows.Add用于添加单行。你将不得不循环遍历

集合并一次添加一行。或者搜索一下

允许一次添加所有行的方法,但我认为没有一行...


As另一种方法是如何让你的方法将每一行添加到表中,因为

传递给你的方法?如果将表传递给方法ByRef,则可以在方法本身内部添加

行。


Public Sub CreateHorizo​​ntalLine(ByRef表As表)

''---循环创建必要的行

对于

''---创建行

昏暗行作为新行


''---添加行到表

Table.Rows.Add(行)

下一页

结束次级


-

此致,


S Justin Gengo,MCP

Web开发人员/程序员

www.aboutfortunate.com


混乱无序。

Nietzsche

" ; Rob Meade < TE ************** @ edaem.bbor>在消息中写道

news:8f ****************** @ text.news.blueyonder.co。 uk ...
Rob,

Table.Rows.Add is meant to add a single row. You''ll have to loop through the
collection and add each row one at a time. Or search out a method that
allows all the rows to be added at once, but I don''t think there is one...

As an alternative how about having your method add each row to the table as
passed into your method? If you pass the table to the method ByRef then the
rows could be added to it inside of the method itself.

Public Sub CreateHorizontalLine(ByRef table As Table)
''---Loop to create necessary rows
For
''---Create row
Dim Row As New Row

''---Add row to table
Table.Rows.Add(Row)
Next
End Sub

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Rob Meade" <te**************@edaem.bbor> wrote in message
news:8f******************@text.news.blueyonder.co. uk...
大家好,

我只是在我的基类中创建一些方法,其中一个返回一个
水平线,格式化为页面为*我*想要它...基本上是一个三个表行的集合。

我今晚发现了TableRowCollection,所以我希望我能够返回一个这些物体里面有我的三行,然后将收藏品分配到桌子......就像......

昏暗的桌子作为表格

Table.Rows.Add(CreateHorizo​​ntalLine())

私有函数CreateHorizo​​ntalLine()As TableRowCollection

Dim TableRowCollection as TableRowCollection

.... <返回TableRowCollection

结束功能

不幸的是 - 这似乎没有用 - 我误解了这个对象的用法吗?或者有人可以指导我正确的方向...

我当然可以只返回一张桌子并添加t把桌子上的一个牢房连接到一个牢房,但这确实有点不必要(也许)筑巢......

任何帮助都会受到赞赏。

关心<消息
Hi all,

I am just making a few methods in my base class, one of which returns a
horizontal line, formatted on the page as *I* want it..its basically a
collection of three table rows.

I discovered the TableRowCollection this evening, so I was hoping that I
could return one of these objects with my three rows inside it, and then
assign the collection to the table...something like...

Dim Table as Table

Table.Rows.Add(CreateHorizontalLine())
Private Function CreateHorizontalLine() As TableRowCollection

Dim TableRowCollection as TableRowCollection

....

Return TableRowCollection

End Function

Unfortunately - this doesn''t seem to work - have I misinterpreted the use
of this object or can someone guide me in the right direction please...

I could of course just return a table and add that to a cell in a row in
the table, but this does kinda make unnecessary (maybe) nesting...

Any help appreciated.

Regards

Rob



add方法只接受onle对象。您可以创建一个TableRows数组

并改为使用AddRange:

table1.Rows.AddRange(CreateHorizo​​ntalLine())


私有函数CreateHorizo​​ntalLine()As TableRow()

Dim ret(1)因为TableRow''创建了一个包含2个元素类型的数组

tablerow

ret(0)= New TableRow

ret(0).Cells.Add(New TableCell)

ret(1)= New TableRow

ret(0).Cells.Add(New TableCell)

返回ret

结束功能


-

HTH,

Phillip Williams
http: //www.societopia.net
http://www.webswapp.com

" Rob Meade"写道:
The add method takes only onle object. You may create an array of TableRows
and use the AddRange instead:
table1.Rows.AddRange(CreateHorizontalLine())

Private Function CreateHorizontalLine() As TableRow()
Dim ret(1) As TableRow ''creates an array of 2 elements of type
tablerow
ret(0) = New TableRow
ret(0).Cells.Add(New TableCell)
ret(1) = New TableRow
ret(0).Cells.Add(New TableCell)
Return ret
End Function

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Rob Meade" wrote:
大家好,

我只是在我的基类中创建一些方法,其中一个返回一个
水平线,格式化在页面上*我*想要它...基本上是一个三个表行的集合。

我今晚发现了TableRowCollection,所以我希望我能够返回其中一个对象,其中包含我的三行,然后将该集合分配给表格......类似于......

昏暗的表格作为表格

Table.Rows.Add(CreateHorizo​​ntalLine())

私有函数CreateHorizo​​ntalLine()As TableRowCollection

Dim TableRowCollection as TableRowCollection

...返回TableRowCollection

结束功能

不幸的是 - 这似乎不起作用 - 我误解了使用
这个对象还是有人可以指导我朝正确的方向发展...

我当然可以回复一个桌面e并将其添加到
表格中的一行中的单元格中,但这样做有点不必要(也许)嵌套......

任何帮助表示赞赏。
问候

Rob
Hi all,

I am just making a few methods in my base class, one of which returns a
horizontal line, formatted on the page as *I* want it..its basically a
collection of three table rows.

I discovered the TableRowCollection this evening, so I was hoping that I
could return one of these objects with my three rows inside it, and then
assign the collection to the table...something like...

Dim Table as Table

Table.Rows.Add(CreateHorizontalLine())
Private Function CreateHorizontalLine() As TableRowCollection

Dim TableRowCollection as TableRowCollection

....

Return TableRowCollection

End Function

Unfortunately - this doesn''t seem to work - have I misinterpreted the use of
this object or can someone guide me in the right direction please...

I could of course just return a table and add that to a cell in a row in the
table, but this does kinda make unnecessary (maybe) nesting...

Any help appreciated.

Regards

Rob



我希望它可以工作。你真的没说什么不起作用?


你能给出完整代码的简化版吗?你的snipet有很多错误的东西......就像你没有创建一个新表或

a新的TableRowCollection,你的表是从未添加到控件或

任何东西......


Karl


-

我的ASP.Net教程
http://www.openmymind.net/

Rob Meade < TE ************** @ edaem.bbor>在消息中写道

news:8f ****************** @ text.news.blueyonder.co。 uk ...
I would expect it to work. You really didn''t say what isn''t working?

Can you give a simplified version of your complete code? Your snipet has a
lot of things wrong with it as-is...like you aren''t creating a NEW table or
a NEW TableRowCollection, and your table is never added to a control or
anything...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Rob Meade" <te**************@edaem.bbor> wrote in message
news:8f******************@text.news.blueyonder.co. uk...
大家好,

我只是在我的基类中创建一些方法,其中一个返回一个
水平线,格式化为页面为*我*想要它...基本上是一个三个表行的集合。

我今晚发现了TableRowCollection,所以我希望我能够返回一个这些物体里面有我的三行,然后将收藏品分配到桌子......就像......

昏暗的桌子作为表格

Table.Rows.Add(CreateHorizo​​ntalLine())

私有函数CreateHorizo​​ntalLine()As TableRowCollection

Dim TableRowCollection as TableRowCollection

.... <返回TableRowCollection

结束功能

不幸的是 - 这似乎没有用 - 我误解了这个对象的用法吗?或者有人可以指导我正确的方向...

我当然可以只返回一张桌子并添加t把桌子上的一个牢房连接到一个牢房,但这确实有点不必要(也许)筑巢......

任何帮助都会受到赞赏。

关心

Rob
Hi all,

I am just making a few methods in my base class, one of which returns a
horizontal line, formatted on the page as *I* want it..its basically a
collection of three table rows.

I discovered the TableRowCollection this evening, so I was hoping that I
could return one of these objects with my three rows inside it, and then
assign the collection to the table...something like...

Dim Table as Table

Table.Rows.Add(CreateHorizontalLine())
Private Function CreateHorizontalLine() As TableRowCollection

Dim TableRowCollection as TableRowCollection

....

Return TableRowCollection

End Function

Unfortunately - this doesn''t seem to work - have I misinterpreted the use
of this object or can someone guide me in the right direction please...

I could of course just return a table and add that to a cell in a row in
the table, but this does kinda make unnecessary (maybe) nesting...

Any help appreciated.

Regards

Rob



这篇关于困惑:TableRowCollection的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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