Changing all cursor types on a form
-
Hello everybody, I want to change the cursors over all input controls (textboxes) on a form in a loop. I tried something like:
foreach(TextBox tb in formclassname) // but instead of a class a var is expected { tb.Cursor = Cursors.No; // change cursor of textboxes }
What's the right code to make the expected operation ? Thank you in advance Frank -- modified at 11:45 Thursday 15th December, 2005 -
Hello everybody, I want to change the cursors over all input controls (textboxes) on a form in a loop. I tried something like:
foreach(TextBox tb in formclassname) // but instead of a class a var is expected { tb.Cursor = Cursors.No; // change cursor of textboxes }
What's the right code to make the expected operation ? Thank you in advance Frank -- modified at 11:45 Thursday 15th December, 2005Assuming you are trying to change the cursors from within the form that the textboxes are on, you can try something like this:
foreach (Control tmp in this.Controls)
if (tmp is TextBox)
tmp.Cursor = Cursors.Hand;Or like this:
foreach (Control tmp in this.Controls)
if (tmp.GetType().Name == "TextBox")
tmp.Cursor = Cursors.Hand;Regards, Polis Can you practice what you teach?
-
Assuming you are trying to change the cursors from within the form that the textboxes are on, you can try something like this:
foreach (Control tmp in this.Controls)
if (tmp is TextBox)
tmp.Cursor = Cursors.Hand;Or like this:
foreach (Control tmp in this.Controls)
if (tmp.GetType().Name == "TextBox")
tmp.Cursor = Cursors.Hand;Regards, Polis Can you practice what you teach?