如果上面的文本框已經填滿,我想要一個按鈕來填充多個文本框。 I.E. IF textbox1 = file.shp THEN textbox2 = openFileDialog如何從c中同一個按鈕中填充多個文本框
我試着做一些長度函數,但是當我選擇一個文件時,textbox1和2都被填充。
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = @"C:\WCGIS\GEOG489\Final\SHP";
openFileDialog1.Title = "Browse Text Files";
openFileDialog1.CheckFileExists = true;
openFileDialog1.CheckPathExists = true;
openFileDialog1.DefaultExt = "txt";
openFileDialog1.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
openFileDialog1.FilterIndex = 2;
openFileDialog1.RestoreDirectory = true;
openFileDialog1.ReadOnlyChecked = true;
openFileDialog1.ShowReadOnly = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
textBox1.Text = openFileDialog1.FileName;
if (textBox1.Text.Length > 1)
{
textBox2.Text = openFileDialog1.FileName;
}
}
}
我希望能夠有一個新的文本框填充每次我點擊「add shape文件」按鈕。如果textbox1已被佔用,我希望textbox2填充。
你能具體談談你正在嘗試做的,到底是什麼問題呢? – user1666620