Ich habe insgesamt 36 Textfelder in einem Formular mit Namen Textfelder als txtBox1, txtBox2 ..... zu txtBox36. Unter ihnen sind einige der textBox auf form_load Ereignis gefüllt.Erhalten Sie alle Textfelder eines Formulars mit ihrem Namen aufsteigend
Ich möchte alle Text boxen Namen erhalten, die in aufsteigender Reihenfolge leer sind.
, was ich habe versucht:
foreach (Control control in this.Controls)
{
if (control is TextBox)
{
if (String.IsNullOrEmpty(control.Text))
{
for (int j = 1; j <= 36; j++)
{
MessageBox.Show(control.Name.ToString());
}
}
}
}
Was es gibt, ist in zufälliger Reihenfolge
txtBox26
txtBox28
txtBox31
txtBox34
txtBox33
txtBox30
txtBox27
txtBox29
txtBox25
txtBox14
txtBox16
txtBox19
txtBox21
txtBox18
txtBox17
txtBox23
txtBox24
txtBox13
txtBox7
txtBox10
txtBox6
txtBox3
txtBox11
txtBox12
&& String.IsNullOrEmpty ((TextBox) i.Text) – Esko
Benötigen Sie etwas außer 'Linq verwenden'? Ich habe es aus Interesse ausprobiert und eine Fehlermeldung erhalten, dass 'ControlCollection keine Definition für Where' enthält. – Equalsk
ja es gibt Fehler, @Equalsk ich möchte nur den TextBox-Namen in aufsteigender Reihenfolge abrufen. Tut mir leid, ich bin hier noob. – Sdp