Results 1 to 9 of 9

Thread: How do i clear the screen?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2003
    Posts
    149

    How do i clear the screen?

    I am making a windows app i have 1 form i want to clear it. I searched the forums, i googled around, and i still have no idea. Oh ya visual studio.net has the best help ive ever seen in any software package. Those microsoft guys are clever bunch. The help is so worthless why even have it?

  2. #2
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    what do you mean by clearing the screen? are you trying to clear up the stuff you've drawn on a windows form? you can just set it's image property to nothing and I guess that would clear it
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  3. #3
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi,

    "The help is so worthless why even have it?"

    MSDN Help is brilliant - provided you know how to use it!!! You HAVE to know precisely what question you are asking. If you ask the wrong question, that is your fault, not Microsoft's.

    Your question is a good example. As MrPolite implies, what you probably DON'T want to do is "Clear the Screen". (If you do actually want to clear the screen without closing the application then simply use the minimise button.)
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  4. #4
    New Member
    Join Date
    May 2004
    Location
    Dubai
    Posts
    5
    If I do understand you correctly, you want to make all textboxes empty? If so, let me know, I may send you an example code, or explain it. It's not that hard. You just need create a "For each" statement and go through Controls collection of a form. Than determine type of a currently selected control and by using "Select Case" or "If End If" you will need create variable of the type of current control, assign that control to a variable and do what ever you want with that control.

  5. #5
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi,

    "If I do understand you correctly, you want to make all textboxes empty?"


    If that is what is wanted the most recent thread to cover it is;

    http://www.vbforums.com/showthread.p...hreadid=288891
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  6. #6
    New Member
    Join Date
    May 2004
    Location
    Dubai
    Posts
    5
    Sorry,

    haven't noticed that post while writting this one.

  7. #7
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi XD

    "Sorry,

    haven't noticed that post while writting this one."


    Don't be sorry. You may have hit upon what the guy wants to do

    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  8. #8
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489

    Re: How do i clear the screen?

    Originally posted by abcdefg
    Oh ya visual studio.net has the best help ive ever seen in any software package. Those microsoft guys are clever bunch. The help is so worthless why even have it?

    so...do you think it's good or do you not like it? you've contadicted yourself.

    Basically, to get the form back to defaults(I assume that's what you mean), you have to write code that will go through each control (text boxes, listboxes, combo-boxes, etc) and either set the text to "" or in some cases you can call the emtpy() method or clear() method.

  9. #9
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    here are some really good routines I wrote (the guys in this forum helped me get these started way back when, what a great forum!!)

    VB Code:
    1. Public Sub ClearListBox(ByVal box As ListBox)
    2.         'Purpose    :   Clear a list box of all items
    3.         'Accepts    :   listbox control
    4.  
    5.         box.Items.Clear()
    6.  
    7.     End Sub
    8.  
    9.     Public Sub ClearTabControl(ByVal tc As TabControl)
    10.         'Purpose    :   clears all tabpages on a tabpage control
    11.         'Accepts    :   control as tabcontrol
    12.  
    13.         For Each Ctrl As Control In tc.Controls
    14.             Try
    15.  
    16.                 If TypeOf Ctrl Is TabPage Then
    17.                     ClearTab(Ctrl)
    18.                 End If
    19.  
    20.             Catch ex As Exception
    21.                 'Catch all errors
    22.                 ErrorMessage(ex.Message)
    23.             End Try
    24.         Next
    25.  
    26.     End Sub
    27.  
    28.     Public Sub ClearTab(ByVal Tab As Control)
    29.         'Purpose    :   Clears an entire tab control of data
    30.         'Accepts    :   tabpage control
    31.         'Notes      :   this sub calls on other subs to do the work
    32.  
    33.         For Each Ctrl As Control In Tab.Controls
    34.  
    35.             Try
    36.  
    37.                 'Scan any tabConrols first
    38.                 If TypeOf Ctrl Is TabControl Then
    39.                     ClearTab(Ctrl)
    40.                 End If
    41.  
    42.                 'Next, other Tabs
    43.                 If TypeOf Ctrl Is TabPage Then
    44.                     ClearTab(Ctrl)
    45.                 End If
    46.  
    47.                 'Clear all textboxes
    48.                 If TypeOf Ctrl Is TextBox Then
    49.                     ClearTextBox(Ctrl)
    50.                 End If
    51.  
    52.                 'Next, ComboBoxes
    53.                 If TypeOf Ctrl Is ComboBox Then
    54.                     ClearComboBox(Ctrl)
    55.                 End If
    56.  
    57.                 'Next, Groupboxes
    58.                 If TypeOf Ctrl Is GroupBox Then
    59.                     ClearGroupBox(Ctrl)
    60.                 End If
    61.  
    62.                 'Next, Listboxes
    63.                 If TypeOf Ctrl Is ListBox Then
    64.                     ClearListBox(Ctrl)
    65.                 End If
    66.  
    67.             Catch ex As Exception
    68.                 'Catch all errors
    69.                 ErrorMessage(ex.Message & Ctrl.Name)
    70.             End Try
    71.  
    72.         Next
    73.  
    74.     End Sub
    75.  
    76.     Public Sub ClearComboBox(ByVal Box As ComboBox)
    77.         'Purpose    :   Resets a combobox to the first item in the collection list
    78.         'Accepts    :   combox as argument
    79.         'Notes      :   This doesn't delete any info, it just resets the box
    80.  
    81.         Try
    82.             Box.Text = Box.Items.Item(0)
    83.  
    84.         Catch ex As Exception
    85.             'Catch all errors
    86.             ErrorMessage(ex.Message & Box.Name)
    87.         End Try
    88.  
    89.     End Sub
    90.  
    91.     Public Sub ClearGroupBox(ByVal groupbox As GroupBox)
    92.         'Purpose    :   Clear all textboxes within a groupbox control
    93.         'Accepts    :   groupbox as argument
    94.  
    95.         For Each ctrl As Control In groupbox.Controls
    96.  
    97.             Try
    98.                 If TypeOf ctrl Is TextBox Then
    99.  
    100.                     ClearTextBox(ctrl)
    101.  
    102.                 End If
    103.  
    104.                 If TypeOf ctrl Is ComboBox Then
    105.  
    106.                     ClearComboBox(ctrl)
    107.  
    108.                 End If
    109.  
    110.                 'If TypeOf ctrl Is ListBox Then
    111.  
    112.                 '    ClearListBox(ctrl)
    113.  
    114.                 'End If
    115.  
    116.             Catch ex As Exception
    117.                 'Catch all errors
    118.                 ErrorMessage(ex.Message)
    119.             End Try
    120.  
    121.         Next
    122.  
    123.  
    124.     End Sub
    125.  
    126.     Public Sub ClearTextBox(ByVal Box As TextBox)
    127.         Box.Text = String.Empty
    128.     End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width