Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

C# clear form

public class Utilities
    {
        public static void ResetAllControls(Control form)
        {
            foreach (Control control in form.Controls)
            {
                if (control is TextBox)
                {
                    TextBox textBox = (TextBox)control;
                    textBox.Text = null;
                }

                if (control is ComboBox)
                {
                    ComboBox comboBox = (ComboBox)control;
                    if (comboBox.Items.Count > 0)
                        comboBox.SelectedIndex = 0;
                }

                if (control is CheckBox)
                {
                    CheckBox checkBox = (CheckBox)control;
                    checkBox.Checked = false;
                }

                if (control is ListBox)
                {
                    ListBox listBox = (ListBox)control;
                    listBox.ClearSelected();
                }
            }
        }
  		
  		private void button1_Click(object sender, EventArgs e)
		{
     		Utilities.ResetAllControls(this);
		}
    }
Comment

PREVIOUS NEXT
Code Example
Csharp :: C# new form 
Csharp :: check if palindrome recursion in c# 
Csharp :: c# get serial ports 
Csharp :: check if value in list c# 
Csharp :: Get the Photon Player GameObject 
Csharp :: c# html to pdf 
Csharp :: c# operator overloading 
Csharp :: And this is how can you deserialize your XML file in your C# code: 
Csharp :: enum c# 
Csharp :: unity tilemap get all tiles 
Csharp :: c# datagridview hide header 
Csharp :: wpf stackpanel 
Csharp :: Data at the root level is invalid. Line 1, position 1. 
Csharp :: stringify c# 
Csharp :: .net 6 autofac 
Csharp :: c# loop through repeater items 
Csharp :: c# modify dictionary in loop 
Csharp :: c# make file not read only 
Csharp :: C# api get value from header 
Csharp :: c# convert double to string 
Csharp :: unity how to create a prefab 
Csharp :: Scrollable WPF ListBox 
Csharp :: add list to list c# 
Csharp :: dynamically add rows to datagridview c# 
Csharp :: select distinct two columns entity framework c# 
Csharp :: combine two arraylist c# 
Csharp :: c# get smallest of 3 numbers 
Csharp :: c# array zaheln speichern 
Csharp :: c sharp teleporting 
Csharp :: csharp 3d array length 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =