Ankit Agarwal

Ankit Agarwal

  • NA
  • 379
  • 252.7k

How to store folderbrowserdialog value in textbox at runtime

Dec 23 2016 1:20 AM
Hello,

I want to create application for runtime for create controls and functionality, controls created successfully but value not storing in text box according folder dialog.
 
private void btnBrowse_Click(object sender, EventArgs e)
{
//LoadControls();
ChooseFolder();
}
public void ChooseFolder()
{
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
TextBox textbox = new TextBox();
textbox.Text = folderBrowserDialog1.SelectedPath;
MessageBox.Show(textbox.Text);
}
}
private void btnAdd_Click(object sender, EventArgs e)
{
int count = panel1.Controls.OfType<Label>().ToList().Count;
TextBox textbox = new TextBox();
count = panel1.Controls.OfType<TextBox>().ToList().Count;
textbox.Location = new Point(3, 25 * count);
textbox.Size = new Size(188, 20);
textbox.Name = "textbox_" + (count + 1);
textbox.TextChanged += new System.EventHandler(this.TextBox_Changed);
panel1.Controls.Add(textbox);
Button button = new Button();
//count = panel1.Controls.OfType<Button>().ToList().Count;
button.Location = new Point(207, 25 * count);
button.Size = new Size(75, 23);
button.Name = "button_" + (count + 1);
button.Text = "Browse " + (count + 1);
button.Click += new System.EventHandler(this.btnBrowse_Click);
panel1.Controls.Add(button);
}
 
Please help me.
How can be resolve that?
 
Thanks
Ankit Agarwal
Software Engineer

Answers (1)