动态控制创建 [英] dynamic control creation

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

问题描述

我有一个继承面板的用户控件(比如myUserControl),我动态地在myUserControl上创建了一些文本框,然后我动态地在窗体上创建了一些

myUserControls一个循环 。当然我更改

名称,位置等..同时。


i在这里有一些问题。


例如:我怎么能到达每个myUserControl和textBoxes这个

myUserControl。

如果我直接联系他们可能会更好,我知道重命名控件

运行时没用。我该怎么办?

另一个问题是,我们不知道myUserControl上有多少个myUserControl或者创建了myUserControl上的
文本框。我需要自动滚动

功能。在面板上它可以工作,但在表格看来,自动滚动

不起作用。


thnkz

解决方案

e-mid。


有不同的方法可以做到这一点,我有一个推荐。


1.要获得单独的控件,请通过属性访问。


示例 -


protected TextBox mMyTextBox;


public TexBox MyTextBox

{

get {return mMyTextBox;}

}


2. Autoscroll甚至可以在表单的设计模式下工作。我不确定为什么

它不能用于你的形式


Shak。

" e-mid" <有人@某处>在消息中写道

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

我有一个用户控件(比如myUserControl)继承了面板,我动态地在myUserControl上创建了一些文本框,然后我用循环动态地在窗体上创建了一些
myUserControls。当然我改变名称,位置等..同时。

我在这里遇到了一些问题。

例如:我怎么能到达每个myUserControl和textBoxes on这个
myUserControl。
我可以更好地直接联系到他们,我知道在运行时重命名控件
是没用的。我该怎么办?

另一个问题是,我们不知道myUserControl上会创建多少个myUserControl或者是myUserControl上的文本框。我需要自动滚动功能。在面板上它可以工作,但在表格看来,自动滚动
不起作用。

thnkz


e-mid。


有不同的方法可以做到这一点,我有一个推荐。


1.达到个人控制,通过属性访问。


示例 -


protected TextBox mMyTextBox;


public TexBox MyTextBox

{

get {return mMyTextBox;}

}


2.自动滚动将起作用即使在形式的设计模式。我不确定为什么

它不能用于你的形式


Shak。

" e-mid" <有人@某处>在消息中写道

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

我有一个用户控件(比如myUserControl)继承了面板,我动态地在myUserControl上创建了一些文本框,然后我用循环动态地在窗体上创建了一些
myUserControls。当然我改变名称,位置等..同时。

我在这里遇到了一些问题。

例如:我怎么能到达每个myUserControl和textBoxes on这个
myUserControl。
我可以更好地直接联系到他们,我知道在运行时重命名控件
是没用的。我该怎么办?

另一个问题是,我们不知道myUserControl上会创建多少个myUserControl或者是myUserControl上的文本框。我需要自动滚动功能。在面板上它可以工作,但在表格看来,自动滚动
不起作用。

thnkz




" Shakir Hussain" < SH ** @ fakedomain.com>在消息中写道

新闻:#j ************** @ tk2msftngp13.phx.gbl ...

e-mid。

有不同的方法,我有一个推荐。

1.达到个人控制,通过属性访问。

示例 -

受保护的TextBox mMyTextBox;

公共TexBox MyTextBox
获取{return mMyTextBox;}

i别想,这个方式有效。动态创建的控件。

这里出现了另一个问题,默认情况下这个控件是私有的吗?

2.自动滚动甚至可以在表单的设计模式下工作。我不确定为什么
它不能用于你的形式


它水平滚动,但垂直自动滚动不起作用..


i不明白为什么?

Shak。

" e-mid" <有人@某处>在消息中写道
新闻:Oi ************** @ TK2MSFTNGP09.phx.gbl ...

我有一个用户控件(比如myUserControl)继承了面板,我动态地在myUserControl上创建了一些文本框,然后我用循环动态地在窗体上创建了一些
myUserControls。当然我改变名称,位置等..同时。

我在这里遇到了一些问题。

例如:我怎么能到达每个myUserControl和textBoxes on这个
myUserControl。
我可以更好地直接联系到他们,我知道在

上重命名控件


运行时没用。我该怎么办?

另一个问题是,我们不知道myUserControl上的
或文本框中会创建多少个myUserControls。我需要自动滚动功能。它在面板上工作,但在表格看来,
autoscroll不起作用。

thnkz



i have a user control (say myUserControl) that inherits panel, i create
some textboxes on myUserControl dynamically, then i create some
myUserControls on the form dynamically with a loop . of course i change
name,location etc.. meanwhile.

i have some problems here then.

eg: how could i reach each myUserControl and textBoxes on this
myUserControl.
it could be betterif i reach them directly, i know renaming a control on
the runtime is useless. what should i do?
another issue is, it is not known how many myUserControls on thye from or
textboxes on a myUserControl will be created. i need autoscroll
functionality. on the panel it works, but on the form it seems, autoscroll
does not work.

thnkz


解决方案

e-mid.

There are different ways to do that, i have one recomendation.

1. To reach individual controls, access through properties.

example -

protected TextBox mMyTextBox;

public TexBox MyTextBox
{
get {return mMyTextBox;}
}

2. Autoscroll will work even in design mode of form. I am not sure why
its not working for ur form

Shak.
"e-mid" <someone@somewhere> wrote in message
news:Oi**************@TK2MSFTNGP09.phx.gbl...

i have a user control (say myUserControl) that inherits panel, i create
some textboxes on myUserControl dynamically, then i create some
myUserControls on the form dynamically with a loop . of course i change
name,location etc.. meanwhile.

i have some problems here then.

eg: how could i reach each myUserControl and textBoxes on this
myUserControl.
it could be betterif i reach them directly, i know renaming a control on the runtime is useless. what should i do?
another issue is, it is not known how many myUserControls on thye from or
textboxes on a myUserControl will be created. i need autoscroll
functionality. on the panel it works, but on the form it seems, autoscroll
does not work.

thnkz



e-mid.

There are different ways to do that, i have one recomendation.

1. To reach individual controls, access through properties.

example -

protected TextBox mMyTextBox;

public TexBox MyTextBox
{
get {return mMyTextBox;}
}

2. Autoscroll will work even in design mode of form. I am not sure why
its not working for ur form

Shak.
"e-mid" <someone@somewhere> wrote in message
news:Oi**************@TK2MSFTNGP09.phx.gbl...

i have a user control (say myUserControl) that inherits panel, i create
some textboxes on myUserControl dynamically, then i create some
myUserControls on the form dynamically with a loop . of course i change
name,location etc.. meanwhile.

i have some problems here then.

eg: how could i reach each myUserControl and textBoxes on this
myUserControl.
it could be betterif i reach them directly, i know renaming a control on the runtime is useless. what should i do?
another issue is, it is not known how many myUserControls on thye from or
textboxes on a myUserControl will be created. i need autoscroll
functionality. on the panel it works, but on the form it seems, autoscroll
does not work.

thnkz




"Shakir Hussain" <sh**@fakedomain.com> wrote in message
news:#j**************@tk2msftngp13.phx.gbl...

e-mid.

There are different ways to do that, i have one recomendation.

1. To reach individual controls, access through properties.

example -

protected TextBox mMyTextBox;

public TexBox MyTextBox
{
get {return mMyTextBox;}
i dont think, this way works. controls created dynamically.
another question arised here , is this controls are private by default?
2. Autoscroll will work even in design mode of form. I am not sure why
its not working for ur form
it scrolls horizontally, but vertical autoscroll does not work..

i did not understand why?
Shak.
"e-mid" <someone@somewhere> wrote in message
news:Oi**************@TK2MSFTNGP09.phx.gbl...

i have a user control (say myUserControl) that inherits panel, i create
some textboxes on myUserControl dynamically, then i create some
myUserControls on the form dynamically with a loop . of course i change
name,location etc.. meanwhile.

i have some problems here then.

eg: how could i reach each myUserControl and textBoxes on this
myUserControl.
it could be betterif i reach them directly, i know renaming a control


on

the runtime is useless. what should i do?
another issue is, it is not known how many myUserControls on thye from or textboxes on a myUserControl will be created. i need autoscroll
functionality. on the panel it works, but on the form it seems, autoscroll does not work.

thnkz




这篇关于动态控制创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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