新建一个组件继承自LayeredListBox,在Dui虚拟控件中添加多个DuiTextBox,在显示后获取的光标有问题,求解决办法,效果图如下:
在你依次选择不同文本框进行文本输入时,之前获取到焦点的文本框不会失去焦点,在填写信息时会同步更新之前所有获取过焦点的文本框,代码如下
public partial class UTextDui : LayeredListBox
{
public UTextDui()
{
}
public void addControls()
{
for (int i = 0; i < 10; i++)
{
DuiBaseControl baseComtrol = new DuiBaseControl();
baseComtrol.Size = new Size(Width, 30);
baseComtrol.BackColor = Color.Transparent;
baseComtrol.Name = "baseControl_"+i.ToString();
int zWidth = (this.Width - 20) / 3;
for (int j = 0; j < 3; j++)
{
DuiTextBox textBox = new DuiTextBox();
textBox.Size = new Size(zWidth,26);
textBox.Location = new Point(5*(j+1)+zWidth*j,2);
textBox.Name = "Text_" + i.ToString() + "_" + j.ToString();
textBox.Text = "Text_" + i.ToString() + "_" + j.ToString();
textBox.BackColor = Color.White;
textBox.BorderRender = new LayeredSkin.DirectUI.FilletBorderRender(15, 1, Color.Blue);
baseComtrol.Controls.Add(textBox);
}
Items.Add(baseComtrol);
RefreshList();
GC.Collect();
}
}
}
代码生成控件添加到窗体上,调用控件的addControl方法即可显示所有文本框,复现问题
|