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
Jayanth Reddy
NA
250
9.9k
To check previous status of dynamic functionalities of form
Jul 9 2019 12:51 AM
Hi there,
I have created dynamic textboxes and according to my requirement textboxes should be saved permenantly on the form along with their properties even if we close and open the app again.Here is my code every thing was fine except retreiving the TextBox from backend after reopening the form.Can anyone help me.I am a beginner.
namespace
WindowsFormsApp1
{
public
partial
class
Form1 : Form
{
public
Form1()
{
InitializeComponent();
}
TextBox tb1;
TextBox tb2;
TextBox tb3;
TextBox tb4;
ComboBox cm;
int
lbltext = 1;
int
X = 1;
int
A = 1;
private
void
Button1_Click(
object
sender, EventArgs e)
{
Show();
X++;
}
private
new
void
Show()
{
if
(X == 1)
{
tb1 =
new
TextBox();
tb1.Text = lbltext.ToString() +
"."
;
tb1.Height = 22;
tb1.Width = 17;
tb1.Left = 9;
tb1.Top = 140 + A * 36;
this
.Controls.Add(tb1);
tb2 =
new
TextBox();
tb2.Height = 22;
tb2.Width = 60;
tb2.Left = 43;
tb2.Top = 140 + A * 36;
this
.Controls.Add(tb2);
tb3 =
new
TextBox();
tb3.Height = 22;
tb3.Width = 64;
tb3.Left = 122;
tb3.Top = 140 + A * 36;
this
.Controls.Add(tb3);
tb4 =
new
TextBox();
tb4.Height = 22;
tb4.Width = 80;
tb4.Left = 220;
tb4.Top = 140 + A * 36;
this
.Controls.Add(tb4);
cm =
new
ComboBox();
cm.Text =
"-NONE-"
;
cm.Items.Add(
"-PRESENT-"
);
cm.Items.Add(
"-LEAVE-"
);
cm.Items.Add(
"-HOLIDAY-"
);
cm.Left = 358;
cm.Width = 92;
cm.Height = 22;
cm.Top = 140 + A * 36;
Controls.Add(cm);
A += 1;
lbltext += 1;
}
else
{
MessageBox.Show(
"Cannot add more than one record at a time"
);
}
}
private
void
Button2_Click(
object
sender, EventArgs e)
{
ExampleDataContext dc =
new
ExampleDataContext();
TextBox4 tb =
new
TextBox4();
var duplicate = (from TextBox4
in
dc.TextBox4s select tb.textvalue);
label1.Text = (duplicate.Count()).ToString();
if
(duplicate.Count() == 0)
{
tb.textvalue = lbltext - 1;
tb.HeightValue = tb1.Height;
tb.WidthValue = tb1.Width;
tb.LeftValue = tb1.Left;
tb.TopValue = tb1.Top;
dc.TextBox4s.InsertOnSubmit(tb);
dc.SubmitChanges();
MessageBox.Show(
"Record inserted successfully"
);
}
else
{
MessageBox.Show(
"Record already exists"
);
}
}
private
void
Form1_Load(
object
sender, EventArgs e)
{
tb1 =
new
TextBox();
ExampleDataContext dc =
new
ExampleDataContext();
TextBox4 tb =
new
TextBox4();
var duplicate = (from TextBox4
in
dc.TextBox4s where tb.textvalue==1 select tb.textvalue);
if
(duplicate.Count()>0)
{
tb1.BorderStyle = BorderStyle.FixedSingle;
tb1.Text = tb.textvalue.ToString();
tb1.Top = tb.TopValue;
tb1.Height = tb.HeightValue;
tb1.Width = tb.WidthValue;
tb1.Left = tb.LeftValue;
this
.Controls.Add(tb1);
}
}
private
void
Button3_Click(
object
sender, EventArgs e)
{
this
.Close();
}
}
}
Reply
Answers (
2
)
What is polymorphism
Fix the Column Header jqgrid