C# Tree控件 背景色重绘
在Tree控件 时间中选择 Leave , BeforeSelect 就OK 了
private void tvFunction_Leave(object sender, EventArgs e)
{
if (tvFunction.SelectedNode != null)
{
//让选中项背景色呈现红色
tvFunction.SelectedNode.BackColor = Color.Blue;
//前景色为白色
tvFunction.SelectedNode.ForeColor = Color.White;
}
}
private void tvFunction_BeforeSelect(object sender, TreeViewCancelEventArgs e)
{
if (tvFunction.SelectedNode != null)
{
//将上一个选中的节点背景色还原(原先没有颜色)
tvFunction.SelectedNode.BackColor = Color.Empty;
//还原前景色
tvFunction.SelectedNode.ForeColor = Color.Black;
}
}
C# WinForm子窗体弹出一个
if (FrmChuangTI .Instance == null || FrmChuangTI .Instance.IsDisposed)
{
Form frm = new Form ();
frm.StartPosition = FormStartPosition.CenterScreen;
frm.Show();
}
else
{
Form .Instance.WindowState = FormWindowState.Normal;
Form .Instance.Show();
Form .Instance.StartPosition = FormStartPosition.CenterScreen;
Form .Instance.Focus();
}
private static FrmChuangTI instance = null;
public static FrmChuangTI Instance
{
get{ return instance;}
}
//或者frm.ShowDialog();
C# 根据路径获取文件夹内容,并删除内容
DirectoryInfo dir = new DirectoryInfo(path);
//path为某个目录,如: “D:\Program Files”
FileInfo[] inf = dir.GetFiles();
foreach (FileInfo finf in inf)
{
if( finf.Extension.Equals(".jpg"))
//如果扩展名为“.xml”
this.label1.Text += finf.FullName+"; ";
//读取文件的完整目录和文件名
finf .delete();
}