Click here to Skip to main content
15,897,518 members
Home / Discussions / C#
   

C#

 
QuestionRe: Hacking Pin
Eddy Vluggen2-Mar-21 12:50
professionalEddy Vluggen2-Mar-21 12:50 
AnswerRe: Hacking Pin
trønderen2-Mar-21 16:29
trønderen2-Mar-21 16:29 
GeneralRe: Hacking Pin
Eddy Vluggen2-Mar-21 16:48
professionalEddy Vluggen2-Mar-21 16:48 
GeneralRe: Hacking Pin
trønderen2-Mar-21 17:38
trønderen2-Mar-21 17:38 
GeneralRe: Hacking Pin
Eddy Vluggen6-Mar-21 10:10
professionalEddy Vluggen6-Mar-21 10:10 
GeneralRe: Hacking Pin
Mycroft Holmes1-Mar-21 11:02
professionalMycroft Holmes1-Mar-21 11:02 
GeneralRe: Hacking Pin
Pete O'Hanlon3-Mar-21 2:03
mvePete O'Hanlon3-Mar-21 2:03 
GeneralRe: Hacking Pin
Eddy Vluggen2-Mar-21 9:56
professionalEddy Vluggen2-Mar-21 9:56 
GeneralRe: Hacking Pin
Gerry Schmitz2-Mar-21 18:29
mveGerry Schmitz2-Mar-21 18:29 
QuestionKnight's tour, recursion, dynamic programming, optimization Pin
Kari Trust28-Feb-21 14:30
Kari Trust28-Feb-21 14:30 
AnswerRe: Knight's tour, recursion, dynamic programming, optimization Pin
trønderen28-Feb-21 15:59
trønderen28-Feb-21 15:59 
GeneralRe: Knight's tour, recursion, dynamic programming, optimization Pin
Kari Trust2-Mar-21 2:04
Kari Trust2-Mar-21 2:04 
GeneralRe: Knight's tour, recursion, dynamic programming, optimization Pin
trønderen2-Mar-21 8:53
trønderen2-Mar-21 8:53 
QuestionApplication crashes suddenly without any message [Solved] Pin
Alex Dunlop26-Feb-21 22:05
Alex Dunlop26-Feb-21 22:05 
AnswerRe: Application crashes suddenly without any message Pin
BillWoodruff26-Feb-21 22:23
professionalBillWoodruff26-Feb-21 22:23 
GeneralRe: Application crashes suddenly without any message Pin
Alex Dunlop26-Feb-21 22:29
Alex Dunlop26-Feb-21 22:29 
GeneralRe: Application crashes suddenly without any message Pin
OriginalGriff26-Feb-21 22:35
mveOriginalGriff26-Feb-21 22:35 
AnswerRe: Application crashes suddenly without any message Pin
OriginalGriff26-Feb-21 22:32
mveOriginalGriff26-Feb-21 22:32 
GeneralRe: Application crashes suddenly without any message Pin
Alex Dunlop26-Feb-21 23:01
Alex Dunlop26-Feb-21 23:01 
QuestionHow to reset TextBoxes at once? [Solved] Pin
Alex Dunlop25-Feb-21 7:06
Alex Dunlop25-Feb-21 7:06 
AnswerRe: How to reset TextBoxes at once? Pin
Gerry Schmitz25-Feb-21 8:42
mveGerry Schmitz25-Feb-21 8:42 
GeneralRe: How to reset TextBoxes at once? Pin
OriginalGriff25-Feb-21 8:51
mveOriginalGriff25-Feb-21 8:51 
GeneralRe: How to reset TextBoxes at once? Pin
Gerry Schmitz25-Feb-21 9:17
mveGerry Schmitz25-Feb-21 9:17 
AnswerRe: How to reset TextBoxes at once? Pin
OriginalGriff25-Feb-21 8:50
mveOriginalGriff25-Feb-21 8:50 
That will work - on textboxes, it won't touch ComboBoxes - provided they aren't inside any containers: Panel, Splitters, GroupBoxes, and so on. If they are, then you need to recurse though the container.Controls collection as well in order to find them.
It will also only find TextBoxes which are in the current instance of a Form - ones in a different Form or a different instance will not be found and cleared.
But in more recent versions of C#, it's clearer to do this than cast:
C#
private void MyButton_Click(object sender, EventArgs e)
    {
    foreach (Control c in Controls)
        {
        if (c is TextBox tb)
            {
            tb.Clear();
            }
        }
    }

"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!

GeneralRe: How to reset TextBoxes at once? Pin
Alex Dunlop25-Feb-21 19:10
Alex Dunlop25-Feb-21 19:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.