Click here to Skip to main content
14,838,359 members
Home / Discussions / C#
   

C#

 
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
MemberAlex Dunlop26-Feb-21 23:01 
QuestionHow to reset TextBoxes at once? [Solved] Pin
Alex Dunlop25-Feb-21 7:06
MemberAlex 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:
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
MemberAlex Dunlop25-Feb-21 19:10 
GeneralRe: How to reset TextBoxes at once? Pin
Dave Kreskowiak25-Feb-21 19:44
mveDave Kreskowiak25-Feb-21 19:44 
GeneralRe: How to reset TextBoxes at once? PinPopular
OriginalGriff25-Feb-21 19:59
mveOriginalGriff25-Feb-21 19:59 
GeneralRe: How to reset TextBoxes at once? Pin
Eddy Vluggen26-Feb-21 6:39
professionalEddy Vluggen26-Feb-21 6:39 
GeneralRe: How to reset TextBoxes at once? Pin
BillWoodruff25-Feb-21 21:43
mveBillWoodruff25-Feb-21 21:43 
AnswerRe: How to reset TextBoxes at once? Pin
Ralf Meier26-Feb-21 3:05
professionalRalf Meier26-Feb-21 3:05 
AnswerRe: How to reset TextBoxes at once? Pin
BillWoodruff25-Feb-21 21:36
mveBillWoodruff25-Feb-21 21:36 
GeneralRe: How to reset TextBoxes at once? Pin
jsc423-Mar-21 0:35
professionaljsc423-Mar-21 0:35 
Questionwhy can we "get away with" creating static Classes outside our Namespace(s) scope (C# language issue) Pin
BillWoodruff25-Feb-21 3:11
mveBillWoodruff25-Feb-21 3:11 
AnswerRe: why can we "get away with" creating static Classes outside our Namespace(s) scope (C# language issue) Pin
OriginalGriff25-Feb-21 5:32
mveOriginalGriff25-Feb-21 5:32 
GeneralRe: why can we "get away with" creating static Classes outside our Namespace(s) scope (C# language issue) Pin
BillWoodruff25-Feb-21 18:26
mveBillWoodruff25-Feb-21 18:26 
GeneralRe: why can we "get away with" creating static Classes outside our Namespace(s) scope (C# language issue) Pin
OriginalGriff25-Feb-21 20:04
mveOriginalGriff25-Feb-21 20:04 
GeneralRe: why can we "get away with" creating static Classes outside our Namespace(s) scope (C# language issue) Pin
Richard Deeming25-Feb-21 21:59
mveRichard Deeming25-Feb-21 21:59 
GeneralRe: why can we "get away with" creating static Classes outside our Namespace(s) scope (C# language issue) Pin
BillWoodruff26-Feb-21 18:35
mveBillWoodruff26-Feb-21 18:35 
GeneralRe: why can we "get away with" creating static Classes outside our Namespace(s) scope (C# language issue) Pin
#realJSOP27-Feb-21 14:05
mva#realJSOP27-Feb-21 14:05 
QuestionI am getting the following error : Method not found: 'Void **************************************************************' Pin
JagadheeshAP25-Feb-21 1:22
MemberJagadheeshAP25-Feb-21 1:22 
AnswerRe: I am getting the following error : Method not found: 'Void **************************************************************' Pin
Victor Nijegorodov25-Feb-21 1:31
MemberVictor Nijegorodov25-Feb-21 1:31 

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.