B
B
bogdanswag2021-09-21 18:06:05
C++ / C#
bogdanswag, 2021-09-21 18:06:05

Textbox doesn't return any value, why?

c# wforms.
There are five textboxes and two comboboxes. I need to save and output this data to .txt.
for some reason, neither the textbox nor the combobox returns a value, be it a Latin/Cyrillic character/number. It took me a long time to figure out what the problem is. there is a similar program, but there is no such problem. Does this mean that there is a problem somewhere in the logic of the program itself?

public Form1()
        {
            InitializeComponent();
            textBox1.MaxLength = 4; textBox2.MaxLength = 4; textBox3.MaxLength = 4; textBox4.MaxLength = 4;

            string path1 = @"C:\\Program Files\\program1\\cfg.txt";

            Directory.CreateDirectory(path);

            using (StreamWriter swriter = new StreamWriter(path1))
            {
                swriter.Write("info1: " + textBox1.Text + " " + textBox2.Text + " " + textBox3.Text + " " + textBox4.Text + "\n"
                    + "info2: " + comboBox1.SelectedItem + "/" + comboBox2.SelectedItem + "\n"
                    + "info3" + textBox5.Text);
            }
        }

just do not hate for the concatenation =)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2021-09-22
@Adler_lug

So in Form1() the textbox doesn't contain anything right after initialization.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question