0
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 OcppDummyClient
{
public partial class Form1 : Form
{
public string[] messages = new string[]
{
"Authorize",
"BootNoficiation"
};
public Panel A;
public Panel B;
public Form1()
{
InitializeComponent();
InitializeForm();
A = new Panel()
{
Width = this.flowLayoutPanel1.Width,
Height = this.flowLayoutPanel1.Height,
BackColor = Color.Black
};
A.Controls.Add(new Button()
{
Text = "Button"
});
B = new Panel()
{
Width = this.flowLayoutPanel1.Width,
Height = this.flowLayoutPanel1.Height,
BackColor = Color.Blue
};
B.Controls.Add(new Button()
{
Text = "Button2"
});
this.flowLayoutPanel1.Controls.Add(A);
this.flowLayoutPanel1.Controls.Add(B);
}
public void InitializeForm()
{
this.comboBox1.Items.AddRange(messages);
}
private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
{
string SelectedValue = this.comboBox1.Text.ToString();
switch(SelectedValue)
{
case "Authorize":
{
A.Visible = true;
B.Visible = false;
break;
}
case "BootNoficiation":
{
A.Visible = false;
B.Visible = true;
break;
}
default:
{
break;
}
}
}
}
}
這就是我的全部代碼,我想知道爲什麼當我改變與組合框事件處理(comboBox1_SelectedValueChanged)的發生內存泄漏。我認爲內存泄漏沒有發生,因爲我已經創建了面板,只是改變了面板屬性(可見)。C#有內存泄漏時,面板屬性更改
可能重複的[爲什麼右鍵單擊在圓的中心創建一個橙點?](http://stackoverflow.com/questions/12692851/why-does-right-clicking-create-an-orange -dot-in-the-the-the-circle) – KeyWeeUsr
你爲什麼認爲有內存泄漏? – Chris
我剛剛在Windows中打開任務管理,並做了一些更改的組合框事件,我的程序內存增加了! – user3773632