using
System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click( object sender, EventArgs e)
{
// 获取文件夹的名称
string [] sDirectories = Directory.GetDirectories(Environment.CurrentDirectory);
foreach ( string sDirectorie in sDirectories)
{
MessageBox.Show(sDirectorie);
}
}
private void button2_Click( object sender, EventArgs e)
{
// 根据条件获取制定文件夹的名称
string [] sDirectories = Directory.GetDirectories(Environment.CurrentDirectory, " *(2) " );
foreach ( string sDirectorie in sDirectories)
{
MessageBox.Show(sDirectorie);
}
}
private void button3_Click( object sender, EventArgs e)
{
string [] sFileNames = Directory.GetFiles(Environment.CurrentDirectory);
foreach ( string sFileName in sFileNames)
{
MessageBox.Show(sFileName);
}
}
private void button4_Click( object sender, EventArgs e)
{
string [] sFileNames = Directory.GetFiles(Environment.CurrentDirectory + @" lang " , " *.dll " );
foreach ( string sFileName in sFileNames)
{
MessageBox.Show(sFileName);
}
}
private void listBox1_DrawItem( object sender, DrawItemEventArgs e)
{
// 创建一个Brush 画没有被选择的项背景 w(1.11)
Brush brNoSelectedBack = Brushes.PaleTurquoise;
// 创建一个Bush 画被选择项的背景 w(1.11)
Brush brSelectedBack = Brushes.Aqua;
// 创建一个Bush 被选择项字体的颜色w(1.11)
Brush brSelectedFore = Brushes.Black;
// 创建一个Bush 未被选择项字体的颜色w(1.11)
Brush brNoSelectedFore = Brushes.Black;
// 创建一个画笔Pen ,画类表每一项的边框w(1.11)
Pen penFocus = new Pen(Brushes.Gray);
// 填充背景为白色w(1.11)
e.Graphics.FillRectangle(Brushes.White, e.Bounds);
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
{
e.Graphics.FillRectangle(brSelectedBack, e.Bounds);
e.Graphics.DrawRectangle(penFocus, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height - 1 );
e.Graphics.DrawString( this .listBox1.Items[e.Index].ToString(), this .listBox1.Font, brSelectedFore, new Rectangle(e.Bounds.X, e.Bounds.Y + 10 , e.Bounds.Width, e.Bounds.Height));
return ;
}
e.Graphics.FillRectangle(brNoSelectedBack, e.Bounds);
e.Graphics.DrawRectangle(penFocus, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height - 1 );
e.Graphics.DrawString( this .listBox1.Items[e.Index].ToString(), this .listBox1.Font, brNoSelectedFore, new Rectangle(e.Bounds.X, e.Bounds.Y + 10 , e.Bounds.Width, e.Bounds.Height));
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click( object sender, EventArgs e)
{
// 获取文件夹的名称
string [] sDirectories = Directory.GetDirectories(Environment.CurrentDirectory);
foreach ( string sDirectorie in sDirectories)
{
MessageBox.Show(sDirectorie);
}
}
private void button2_Click( object sender, EventArgs e)
{
// 根据条件获取制定文件夹的名称
string [] sDirectories = Directory.GetDirectories(Environment.CurrentDirectory, " *(2) " );
foreach ( string sDirectorie in sDirectories)
{
MessageBox.Show(sDirectorie);
}
}
private void button3_Click( object sender, EventArgs e)
{
string [] sFileNames = Directory.GetFiles(Environment.CurrentDirectory);
foreach ( string sFileName in sFileNames)
{
MessageBox.Show(sFileName);
}
}
private void button4_Click( object sender, EventArgs e)
{
string [] sFileNames = Directory.GetFiles(Environment.CurrentDirectory + @" lang " , " *.dll " );
foreach ( string sFileName in sFileNames)
{
MessageBox.Show(sFileName);
}
}
private void listBox1_DrawItem( object sender, DrawItemEventArgs e)
{
// 创建一个Brush 画没有被选择的项背景 w(1.11)
Brush brNoSelectedBack = Brushes.PaleTurquoise;
// 创建一个Bush 画被选择项的背景 w(1.11)
Brush brSelectedBack = Brushes.Aqua;
// 创建一个Bush 被选择项字体的颜色w(1.11)
Brush brSelectedFore = Brushes.Black;
// 创建一个Bush 未被选择项字体的颜色w(1.11)
Brush brNoSelectedFore = Brushes.Black;
// 创建一个画笔Pen ,画类表每一项的边框w(1.11)
Pen penFocus = new Pen(Brushes.Gray);
// 填充背景为白色w(1.11)
e.Graphics.FillRectangle(Brushes.White, e.Bounds);
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
{
e.Graphics.FillRectangle(brSelectedBack, e.Bounds);
e.Graphics.DrawRectangle(penFocus, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height - 1 );
e.Graphics.DrawString( this .listBox1.Items[e.Index].ToString(), this .listBox1.Font, brSelectedFore, new Rectangle(e.Bounds.X, e.Bounds.Y + 10 , e.Bounds.Width, e.Bounds.Height));
return ;
}
e.Graphics.FillRectangle(brNoSelectedBack, e.Bounds);
e.Graphics.DrawRectangle(penFocus, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height - 1 );
e.Graphics.DrawString( this .listBox1.Items[e.Index].ToString(), this .listBox1.Font, brNoSelectedFore, new Rectangle(e.Bounds.X, e.Bounds.Y + 10 , e.Bounds.Width, e.Bounds.Height));
}
}
}