TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
John Woodiwiss
NA
21
742
Textbox array does not update in a User Control
Jan 21 2020 5:54 PM
Hello everyone,
I am attempting to build a User Control with a collection of TextBoxes. The idea is to be able to display a collection of information.
I can get a single Textbox to update, but I just can't get an array to do the same thing.
The function _aTextBox() is called from 2 buttons on my main program as follows:
private
void
button1_Click(object sender, EventArgs e)
{
ucTextBox1._aTextBox(
"Hello"
,0);
}
private
void
button2_Click(object sender, EventArgs e)
{
ucTextBox1._aTextBox(
"World"
,1);
}
Any and all suggestions welcomed . Many thanks for your time reading this.
My User Control code is below:
At the line marked with // *********************, txt[0].Text holds the correct string. However, it never displays it!!!
namespace
ucTextBox
{
public
partial
class
ucTextBox: UserControl
{
public
ucTextBox()
{
InitializeComponent();
}
TextBox[] txt =
new
TextBox[2];
private
void
DisplayTextBoxes()
{
txt[0] =
new
TextBox();
txt[0].Location =
new
System.Drawing.Point(20, 48);
this
.Controls.Add(txt[0]);
}
public
void
_aTextBox(
string
text)
{
DisplayTextBoxes();
txt[0].Visible =
false
;
txt[0].Text = text;
// *********************
txt[0].Visible =
true
;
txt[0].Invalidate();
txt[0].Update();
txtValue.Visible =
true
;
txtValue.Text = text;
txt[0].ResumeLayout(
true
);
}
}
}
Reply
Answers (
1
)
Want to change the label of a Read Only Text box
Selecting a Row from List View throws an error