C
C#13mo ago
FloW

✅ Text box color changing

how to change color for every text box which contain text "Red" ?
48 Replies
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
FloW
FloWOP13mo ago
there is many text box (300), after user press "generate" all text box values changing I want to make textbox with the bigest value red
Omnissiah
Omnissiah13mo ago
we're asking for the type name of the textbox
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
FloW
FloWOP13mo ago
Winform
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
FloW
FloWOP13mo ago
Yes
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
FloW
FloWOP13mo ago
TextBox Класс (System.Windows.Forms)
Предоставляет элемент управления "текстовое поле" Windows.
FloW
FloWOP13mo ago
BackColor?
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
FloW
FloWOP13mo ago
I think yes Ehh....
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
FloW
FloWOP13mo ago
I mean , how to change bg for every textbox which contain "red"
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
FloW
FloWOP13mo ago
I know but maybe my teacher didn't hear about this
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
FloW
FloWOP13mo ago
.
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
DeepInside
DeepInside13mo ago
foreach (Control control in this.Controls) { if (control is TextBox textBox && textBox.Text.Contains("Red")) { textBox.ForeColor = Color.Red; } }
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
DeepInside
DeepInside13mo ago
Do you mean something like this?
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
DeepInside
DeepInside13mo ago
Oops, sorry
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
Omnissiah
Omnissiah13mo ago
it would be too wild
FloW
FloWOP13mo ago
±
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
DeepInside
DeepInside13mo ago
I understand
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
FloW
FloWOP13mo ago
int[,] arr = new int[15, 20];
private void button1_Click(object sender, EventArgs e)
{
Random randomGenerator = new Random();
for (int i = 0; i<15; i++)
{
for (int j = 0; j<20; j++)
{
int TextNum = randomGenerator.Next((int)numericUpDown1.Value, (int)numericUpDown2.Value);
arr[i, j] = TextNum;
TextBox textBox = new TextBox()
{
Text = TextNum.ToString(),
Location = new Point(40 + 105 * i, 40 + 30 * j),
Width = 100,
Height = 25,
};

Controls.Add(textBox);
}
}

for (int i=0; i<15; i++)
{
for (int j = 0; j < 20; j++)
{
Console.WriteLine(arr[i, j]);
}
}
}
int[,] arr = new int[15, 20];
private void button1_Click(object sender, EventArgs e)
{
Random randomGenerator = new Random();
for (int i = 0; i<15; i++)
{
for (int j = 0; j<20; j++)
{
int TextNum = randomGenerator.Next((int)numericUpDown1.Value, (int)numericUpDown2.Value);
arr[i, j] = TextNum;
TextBox textBox = new TextBox()
{
Text = TextNum.ToString(),
Location = new Point(40 + 105 * i, 40 + 30 * j),
Width = 100,
Height = 25,
};

Controls.Add(textBox);
}
}

for (int i=0; i<15; i++)
{
for (int j = 0; j < 20; j++)
{
Console.WriteLine(arr[i, j]);
}
}
}
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
FloW
FloWOP13mo ago
No , because it's contain some value For example red Just example
DeepInside
DeepInside13mo ago
You may use .HasChildren property
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
DeepInside
DeepInside13mo ago
What's wrong with recursion?
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
FloW
FloWOP13mo ago
All task sounds like Find the largest number for num%8==0 and make textbox which contains it Red
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
FloW
FloWOP13mo ago
But how can I know that later won't be generated textbox which contain larger number?
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
DeepInside
DeepInside13mo ago
Every time you make me textbox, add it to list Then you can just loop through list
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
DeepInside
DeepInside13mo ago
Yes
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
FloW
FloWOP13mo ago
Hm I can use value like id To find textbox and change color
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
FloW
FloWOP13mo ago
Good luck Thank you all
Want results from more Discord servers?
Add your server