Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
.NET
.NET Core
.NET MAUI
.NET Standard
Active Directory
ADO.NET
Agile Development
AI
AJAX
AlbertAGPT
Alchemy
Alexa Skills
Algorand
Algorithms in C#
Android
Angular
ArcObject
ASP.NET
ASP.NET Core
Augmented Reality
Avalanche
AWS
Azure
Backbonejs
Big Data
BizTalk Server
Blazor
Blockchain
Bootstrap
Bot Framework
Business
Business Intelligence(BI)
C#
C# Corner
C# Strings
C, C++, MFC
Career Advice
Careers and Jobs
Chapters
ChatGPT
Cloud
Coding Best Practices
Cognitive Services
COM Interop
Compact Framework
Copilot
Cortana Development
Cosmos DB
Cryptocurrency
Cryptography
Crystal Reports
CSS
Current Affairs
Custom Controls
Cyber Security
Data Mining
Data Science
Databases & DBA
Databricks
Design Patterns & Practices
DevExpress
DevOps
DirectX
Dynamics CRM
Enterprise Development
Entity Framework
Error Zone
Exception Handling
F#
Files, Directory, IO
Flutter
Games Programming
GDI+
General
Generative AI
GO
Google Cloud
Google Development
Graphics Design
Graphite Studio
Hardware
Hiring and Recruitment
HoloLens
How do I
HTML 5
Infragistics
Internet & Web
Internet of Things
Ionic
Java
Java and .NET
JavaScript
JQuery
JSON
JSP
Knockout
Kotlin
Langchain
Leadership
Learn .NET
Learn iOS Programming
LINQ
Machine Learning
Metaverse
Microsoft 365
Microsoft Fabric
Microsoft Office
Microsoft Phone
Microsoft Teams
Mobile Development
MongoDB
MuleSoft
MySQL
NEAR
NetBeans
Networking
NFT
NoCode LowCode
Node.js
Office Development
OOP/OOD
Open Source
Operating Systems
Oracle
Outsourcing
Philosophy
PHP
Polygon
PostgreSQL
Power Apps
Power Automate
Power BI
Power Pages
Printing in C#
Products
Progress
Progressive Web Apps
Project Management
Public Speaking
Python
Q#
QlikView
Quantum Computing
R
React
React Native
Reports using C#
Robotics & Hardware
RPA
Ruby on Rails
RUST
Salesforce
Security
Servers
ServiceNow
SharePoint
Sharp Economy
SignalR
Smart Devices
Snowflake
Software Architecture/Engineering
Software Testing
Solana
Solidity
Sports
SQL
SQL Server
Startups
Stratis Blockchain
Swift
SyncFusion
Threading
Tools
TypeScript
Unity
UWP
Visual Basic .NET
Visual Studio
Vue.js
WCF
Wearables
Web API
Web Design
Web Development
Web3
Windows
Windows Controls
Windows Forms
Windows PowerShell
Windows Services
Workflow Foundation
WPF
Xamarin
XAML
XML
XNA
XSharp
Register
Login
2
Answers
To check previous status of dynamic functionalities of form
Jayanth Reddy
5y
776
1
Reply
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();
}
}
}
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
What is polymorphism
Fix the Column Header jqgrid