-1-
-2-
0025 حذف الأادوات من الشاشة Remove Or Delete Controls from form In C Sharp تعليم سي شارب
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace wfa0025
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//this.Controls[0].Dispose();
// this.Controls["textBox1"].Dispose();
//this.Controls["textBox4"].Dispose();
//foreach (Control item in Controls)
//{
// item.Dispose();
//}
if(this.Controls["textBox1"]!=null)
this.Controls["textBox1"].Dispose();
}
private void button2_Click(object sender, EventArgs e)
{
string dd = " ";
foreach (Control item in Controls)
{
dd+=item.Name + "\r\n";
}
MessageBox.Show(dd);
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void Form1_MouseClick(object sender, MouseEventArgs e)
{
foreach (Control item in Controls)
{
item.Dispose();
}
}
private void button3_Click(object sender, EventArgs e)
{
foreach (Control item in Controls)
{
item.Hide();
}
button4.Show();
}
private void button4_Click(object sender, EventArgs e)
{
foreach (Control item in Controls)
{
item.Show();
}
}
private void button5_Click(object sender, EventArgs e)
{
int c = this.Controls.Count;
for (int i = 0; i < c; i++)
{
this.Controls[i].Dispose();
}
}
}
}
-3-
-4-