谭0城
2017-03-26 15:16
采纳率: 100%
浏览 3.5k

如何用C#里面的winform窗体内的标签通过上一页和下一页的按钮进行切换?

本人小白,现在做一个软件,需要26个英文字母播放,但是,如果做成图片插入的话,文件总的加起来有点大,所以想用标签来回切换播放字母,另外,上一页和下一页怎么写?用图片有教程,可以做,但是用标签,我不会,百度了一天也没百度出来,请问大神,该怎么写?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • 战在春秋 2017-03-26 22:19
    已采纳

    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();
            }
    
    
    
    点赞 评论
  • blownewbee 2017-03-26 15:18

    做多个panel,每个装入一个页的内容,上一页下一页就将对应的panel调用BringToFront

    点赞 评论
  • JackyRao 2017-04-06 02:32

    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();
        }
    }
    

    }

    点赞 评论

相关推荐 更多相似问题