me.name的问题 [英] problem with me.name

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

问题描述

好的我有一个从另一个类继承的控件。在孩子中我将
将msgbox(me.name)放入load事件中。总是弹出的是父类的名称

而不是对象实例的名称。为什么?另外

如果我能弄清楚这一点我希望我可以把这个放在父母的加载事件中,并且仍然让它工作。

解决方案

尝试MyClass.Name而不是Me.Name。

" Altman" <否****** @ SickOfSpam.com>在留言中写道

新闻:e2 ************** @ TK2MSFTNGP09.phx.gbl ...

好我有一个控件继承自另一个类。在孩子中我将msgbox(me.name)放在load事件中。总是弹出的是父类的名称,而不是对象实例的名称。为什么?
如果我能想到这一点,我希望我可以把它放在父母的负载
事件中并仍然让它工作。



这也不起作用。这里有一些更具体的细节。


我有一个名为BaseControl的类

我有一个名为Bin的类,它继承了basecontrol


我把bin放在一个表单上,并在name属性中用Bin1填充它。

当我把myclass.name或me.name或mybase.name放在msgbox()中时在basecontrol类或Bin类的负载

事件中我总是得到Bin

我希望它说Bin1。


" Scott M." < S - *** @ nospam.nospam>在消息中写道

news:eF ************** @ tk2msftngp13.phx.gbl ...

改为尝试MyClass.Name Me.Name。

" Altman" <否****** @ SickOfSpam.com>在消息中写道
新闻:e2 ************** @ TK2MSFTNGP09.phx.gbl ...

好我有一个继承自的控件另一堂课。在孩子中我将msgbox(me.name)放在load事件中。总是弹出的是父类的名称
而不是对象实例的名称。为什么?
如果我能想到这一点,我希望我可以把它放在父母的负载
事件中并仍然让它工作。




奥特曼,


我不明白你,当你看到这段代码时,出现了什么问题。

您的意见。不要这样做,这只是为了测试。

\\\

类mytextbox

继承System.Windows。 Forms.TextBox

朋友子showame()

Me.Name =" myname"

MessageBox.Show(Me.Name)

结束次级

结束班级

级别亚军

私人名称As String =" mytest"

朋友子跑()

Dim mytexb作为新的mytextbox

MessageBox.Show(Me.name)

mytexb.showname()

结束子

结束班

班级mytest

公共共享子主()

Dim a As New Runner

a.run()

End Sub

End Class

// //


" Altman" < No ****** @ SickOfSpam.com>

好我有一个从另一个类继承的控件。在孩子中我将msgbox(me.name)放在load事件中。总是弹出的是父类的名称,而不是对象实例的名称。为什么?
如果我能想到这一点,我希望我可以把它放在父母的负载
事件中并仍然让它工作。



Ok I have a control that is inherited from another class. In the child I
put msgbox(me.name) in the load event. What always pops up is the name of
the parent class and not the name of the instance of the object. WHY? Also
if I can figure this out I''m hoping that I can put this in the load event of
the parent and still get it to work.

解决方案

Try MyClass.Name instead of Me.Name.
"Altman" <No******@SickOfSpam.com> wrote in message
news:e2**************@TK2MSFTNGP09.phx.gbl...

Ok I have a control that is inherited from another class. In the child I
put msgbox(me.name) in the load event. What always pops up is the name of
the parent class and not the name of the instance of the object. WHY?
Also if I can figure this out I''m hoping that I can put this in the load
event of the parent and still get it to work.



That doesn''t work either. Here is a little more specifics.

I have a class called BaseControl
I have a class called Bin which inherits basecontrol

I put the bin on a form and in the name property I filled it in with Bin1.
When I put myclass.name or me.name or mybase.name in a msgbox() in the load
event of either the basecontrol class or the Bin class I always get "Bin"
and I want it to say "Bin1."

"Scott M." <s-***@nospam.nospam> wrote in message
news:eF**************@tk2msftngp13.phx.gbl...

Try MyClass.Name instead of Me.Name.
"Altman" <No******@SickOfSpam.com> wrote in message
news:e2**************@TK2MSFTNGP09.phx.gbl...

Ok I have a control that is inherited from another class. In the child I
put msgbox(me.name) in the load event. What always pops up is the name
of the parent class and not the name of the instance of the object. WHY?
Also if I can figure this out I''m hoping that I can put this in the load
event of the parent and still get it to work.




Altman,

I do not understand you, when you see this code, what is than going wrong in
your opinion. Do not do it this way, this is only to test.
\\\
Class mytextbox
Inherits System.Windows.Forms.TextBox
Friend Sub showname()
Me.Name = "myname"
MessageBox.Show(Me.Name)
End Sub
End Class
Class Runner
Private name As String = "mytest"
Friend Sub run()
Dim mytexb As New mytextbox
MessageBox.Show(Me.name)
mytexb.showname()
End Sub
End Class
Class mytest
Public Shared Sub main()
Dim a As New Runner
a.run()
End Sub
End Class
////

"Altman" <No******@SickOfSpam.com>

Ok I have a control that is inherited from another class. In the child I
put msgbox(me.name) in the load event. What always pops up is the name of
the parent class and not the name of the instance of the object. WHY?
Also if I can figure this out I''m hoping that I can put this in the load
event of the parent and still get it to work.



这篇关于me.name的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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