这是什么意思? [英] What does it mean?

查看:78
本文介绍了这是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




有人会为我解释以下编码更多细节吗?什么是

()?

CurrentText =(TextBox)e.Item.Cells [i] .Controls [0];

谢谢。


杰森

Hi,

Would someone explain the following coding more detail for me? What''s the
( ) for?
CurrentText = (TextBox)e.Item.Cells[i].Controls[0];
Thanks.

Jason

推荐答案

这是演员。(类型演员),有一个看看这篇文章,看看它是否为你解释了什么
http://www.csharphelp.com/archives2/archive336.html


希望这会有所帮助


Publicjoe


C#教程 http://www.publicjoe.f9.co.uk/csharp/tut.html

C#Ebook at http://www.publicjoe.f9.co.uk/csharp/samples/ebook.html

VB教程在 http: //www.pu blicjoe.f9.co.uk/vbnet/vbnet.html

VB电子书在 http://www.publicjoe.f9.co.uk/vbnet/samples/ebook.html

镜子在 http://dowhileloop.com/publicjoe/
http://publicjoe.dowhileloop.com


" Jason Huang < JA ************ @ hotmail.com>在消息中写道

新闻:Ol ************* @ TK2MSFTNGP12.phx.gbl ...
This is a cast.(type casting), have a look at this article to see if it
explains things for you
http://www.csharphelp.com/archives2/archive336.html

Hope this helps

Publicjoe

C# Tutorial at http://www.publicjoe.f9.co.uk/csharp/tut.html
C# Ebook at http://www.publicjoe.f9.co.uk/csharp/samples/ebook.html
VB Tutorial at http://www.publicjoe.f9.co.uk/vbnet/vbnet.html
VB Ebook at http://www.publicjoe.f9.co.uk/vbnet/samples/ebook.html
Mirrors at http://dowhileloop.com/publicjoe/ and
http://publicjoe.dowhileloop.com

"Jason Huang" <Ja************@hotmail.com> wrote in message
news:Ol*************@TK2MSFTNGP12.phx.gbl...


有人会为我解释以下编码更多细节吗?什么是
()?
CurrentText =(TextBox)e.Item.Cells [i] .Controls [0];
谢谢。

Jason
Hi,

Would someone explain the following coding more detail for me? What''s the
( ) for?
CurrentText = (TextBox)e.Item.Cells[i].Controls[0];
Thanks.

Jason





" Jason Huang" < JA ************ @ hotmail.com>在消息中写道

新闻:Ol ************* @ TK2MSFTNGP12.phx.gbl ...

"Jason Huang" <Ja************@hotmail.com> wrote in message
news:Ol*************@TK2MSFTNGP12.phx.gbl...


有人会为我解释以下编码更多细节吗?什么是
()?
CurrentText =(TextBox)e.Item.Cells [i] .Controls [0];
Hi,

Would someone explain the following coding more detail for me? What''s the
( ) for?
CurrentText = (TextBox)e.Item.Cells[i].Controls[0];




类型转换,以便''e.Item.Cells [i] .Controls [0];''的结果是''TextBox'类型的

对象。


-

S?ren Reinke
www.Xray-Mag.com/ - 网上免费潜水杂志。

当前问题北美潜水,99页。

下载PDF格式



Typecasting, so that the result of ''e.Item.Cells[i].Controls[0];'' is an
object of the type ''TextBox''

--
S?ren Reinke
www.Xray-Mag.com/ - Your free diving magazin on the net.
Current issue Diving in North America, 99 pages.
Download it in PDF


看起来''e''是网格或某种类型的列表......可能是第三方

控制。

Item方法允许你深入挖掘控件的列表元素。


Cells [i]是一个单元格或列表元素的数组。这看起来像一个单独的

列表或一列网格?

因此,值[i]选择列表中的i元素(通常是计数)

从零开始。

注意:如果列表没有i在其中的元素,然后这个声明将

生成错误。


看起来您的控件中的每个单元格都可以容纳多个控件

(完全有效)。但是,原始程序员期望在该单元格中至少有一个控件有
。他/她指的是

单元格中的第一个控件作为控件[0]。注意:如果单元格不包含控件,则此

语句将生成错误。


同一个开发人员希望第一个控件是文本框。注意:如果

它不是文本框,则此语句将生成错误。


开发人员使用强制转换让语言知道它应该对待

第一个控件,在控件列表中,作为文本框。

该值赋给变量CurrentText


注意:如果变量CurrentText是一个字符串变量,那么原始的
开发人员可能应该在TextBox上调用一个方法来返回

的实际文本内容。这可能是意图,虽然它没有这样编码




因此,假设这个语句编译,这个语句将返回

来自可编辑列表或网格中单元格的文本框控件,或者它会引发许多运行时错误之一。


-

--- Nick Malik [微软]

MCSD,CFPS,认证Scrummaster
http://blogs.msdn.com/nickmalik


免责声明:本论坛发表的意见是我自己的,不是

我不代表我的雇主回答问题。我只是一个帮助程序员的
程序员。

-

Jason Huang < JA ************ @ hotmail.com>在消息中写道

新闻:Ol ************* @ TK2MSFTNGP12.phx.gbl ...
Looks like ''e'' is a grid or list of some kind... possibly a third party
control.
The Item method allows you to dig into the list elements of the control.

Cells[i] is an array of cells or list elements. This looks like a single
list or a one-column grid?
So, the value [i] selects the "i"th element in the list (usually counting
from zero).
Note: if the list does not have "i" elements in it, then this statement will
generate an error.

It looks like each cell in your control can hold multiple controls
(perfectly valid). However, the original programmer expects that there is
at least one control in that cell. s/he refers to that first control in the
cell as controls[0]. Note: if the cell does not contain a control, this
statement will generate an error.

The same developer expects that the first control is a text box. Note: if
it is not a textbox, this statement will generate an error.

The developer used casting to let the language know that it should treat the
first control, in the controls list, as a text box.
That value is assigned to the variable CurrentText

Note: if the variable CurrentText is a string variable, then the original
developer should probably have called a method on the TextBox to return the
actual text contents. That is probably the intent, although it isn''t coded
that way.

Therefore, assuming this statement compiles, this statement will return the
textbox control from a cell in an editable list or grid, or it throws one of
many runtime errors.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I''m just a
programmer helping programmers.
--
"Jason Huang" <Ja************@hotmail.com> wrote in message
news:Ol*************@TK2MSFTNGP12.phx.gbl...


有人会为我解释以下编码更多细节吗?什么是
()?
CurrentText =(TextBox)e.Item.Cells [i] .Controls [0];
谢谢。

Jason
Hi,

Would someone explain the following coding more detail for me? What''s the
( ) for?
CurrentText = (TextBox)e.Item.Cells[i].Controls[0];
Thanks.

Jason



这篇关于这是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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