本人小白,现在做一个软件,需要26个英文字母播放,但是,如果做成图片插入的话,文件总的加起来有点大,所以想用标签来回切换播放字母,另外,上一页和下一页怎么写?用图片有教程,可以做,但是用标签,我不会,百度了一天也没百度出来,请问大神,该怎么写?
String[] Contents = { "a", "b" ,"c","d","e", "f" ,"g","h", "i" ,"j","k", "l" ,"m","n", "o" ,"p","q", "r" ,"s" ,"t", "u" ,"v","w", "x" ,"y","z"};//存入26个字母
int currentIndex = 0;//设置初始显示为字母a
假设标签名字为LabelContent,在属性中设置其初值Text为a
上一页按钮假如设为BtnPrevious,其响应事件:
private void BtnPrevious_Click(object sender, EventArgs e)
{
currentIndex -= 1;
if (currentIndex < 0)
{
LabelContent.Text = Contents.GetValue(25).ToString();
currentIndex = 25;
}
else
LabelContent.Text = Contents.GetValue(currentIndex).ToString();
}
下一页按钮假定为 BtnNext,其响应函数为
private void BtnNext_Click(object sender, EventArgs e)
{
currentIndex += 1;
if (currentIndex > 25)
{
LabelContent.Text = Contents.GetValue(0).ToString();
currentIndex = 0;
}
else
LabelContent.Text = Contents.GetValue(currentIndex ).ToString();
}
做多个panel,每个装入一个页的内容,上一页下一页就将对应的panel调用BringToFront
namespace Test
{
public partial class Form1 : Form
{
private int Postion;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Postion = 65;
this.LB_SHOW.Text = ((char)Postion).ToString();
}
private void BTN_SUB_Click(object sender, EventArgs e)
{
if (Postion<=65)
{
Postion = 65 + 25;
}
else
{
Postion--;
}
this.LB_SHOW.Text = ((char)Postion).ToString();
}
private void BTN_ADD_Click(object sender, EventArgs e)
{
if (Postion >= 65+25)
{
Postion = 65 ;
}
else
{
Postion++;
}
this.LB_SHOW.Text = ((char)Postion).ToString();
}
}
}