C#做图片浏览器,在组合框显示中文
这是我写的代码(C#)private ArrayList arrPath = new ArrayList();//路径
private int index = -1;//当前图片为无
private void MainForm_Load(object sender, EventArgs e)
{
openFileDialog.Multiselect = true;
openFileDialog.Filter = "图像文件(*.BMP;*.JPG;*.GIF;*.jpeg)|*.BMP;*.JPG;*.GIF;*.jpeg";
cbSizeMode.Items.Add(PictureBoxSizeMode.Normal);//载入模式//组合框从这里
cbSizeMode.Items.Add(PictureBoxSizeMode.StretchImage);
cbSizeMode.Items.Add(PictureBoxSizeMode.AutoSize);
cbSizeMode.Items.Add(PictureBoxSizeMode.CenterImage);
cbSizeMode.Items.Add(PictureBoxSizeMode.Zoom);//到这里
cbSizeMode.SelectedIndex = 0;
timer.Interval = 2000;
}
private void btnOpen_Click(object sender, EventArgs e)//选择图片
{
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
if (openFileDialog.FileNames.Length != -1)
{
foreach (string s in openFileDialog.FileNames)
{
arrPath.Add(s);
}
index = 0;
pictureBox.Load(arrPath[index].ToString());
}
}
}
private void btnPeriod_Click(object sender, EventArgs e)//上一张
{
if (index != -1)
{
index = (index == 0) ? (arrPath.Count - 1) : (--index);
for (int i = 0; i <= index; i++)
{
pictureBox.Load(arrPath[i].ToString());
}
}
}
private void btnNext_Click(object sender, EventArgs e)//下一张
{
if (index != -1)
{
index = (index == arrPath.Count - 1) ? 0 : (++index);
for (int j = 0; j <= index; j++)
{
pictureBox.Load(arrPath[j].ToString());
}
}
}
private void cbSizeMode_SelectedIndexChanged(object sender, EventArgs e)//图片显示模式
{
pictureBox.SizeMode = (PictureBoxSizeMode)cbSizeMode.SelectedItem;//这里说找不到格式转换//这整个代码语句没事,我只是想把英文模式改为中文模式显示
}
private void timer_Tick(object sender, EventArgs e)//自动换下一张
{
if (chkAutoPlay.Checked == true)
{
if (index != -1)
{
index = (index == arrPath.Count - 1) ? 0 : (++index);
pictureBox.Load(arrPath[index].ToString());
}
}
}
private void chkAutoPlay_CheckedChanged(object sender, EventArgs e)//是否使用timerl
{
timer.Enabled = chkAutoPlay.Checked;
}
}
}
不管我在代码里加上中文,还是在Items里加.都是说找不到转换.想在组合框里能显示中文,请高手帮忙!~!~!~
[ 本帖最后由 sbwfnso 于 2010-3-31 17:27 编辑 ]