如何创建具有多个值的标签框,以及如何使其成为垂直滚动控制它 [英] How do I create a label box with multiple values, and how do I make it so a vertical scroll controls it

查看:62
本文介绍了如何创建具有多个值的标签框,以及如何使其成为垂直滚动控制它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在C#控制台应用程序中制作了Prime数字打印机如何在视觉工作室中使用Windows窗体进行制作

PS我知道我可以提高效率,我正在开发一个但我如何将其带入Visual GUI



共享相册 - 刻录Blaze - Google相册 [ ^ ]



我尝试过:



我的代码

So i have made a Prime Numbers Printer in C# console app how do i make it using the Windows form in visual studio
P.S i know i can make it more efficient and i am working on one but how do i bring this into the Visual GUI

Shared album - Burning Blaze - Google Photos[^]

What I have tried:

My code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PM_gui
{
    public partial class TBFromWhere : Form
    {
        public TBFromWhere()
        {
            InitializeComponent();
        }

        private void ButGen_Click(object sender, EventArgs e)
        {
            int NB1, NB2;
            NB1 = Convert.ToInt32(textBox1.Text);
            NB2 = Convert.ToInt32(TBTillWhere.Text);
            while (NB1 < NB2)
            {
                if (NB1 < NB2)
                {
                    bool Prime = true;
                    if (NB1 % 2 == 0)
                    {
                        Prime = false;
                    }
                    for (int i = 3; i * i <= NB1; i += 2)
                    {
                        if (NB1 % i == 0)
                        {
                            Prime = false;
                        }
                    }
                    if (Prime == true)
                    {
                        label3.Text = NB1.ToString("n");
                    }
                    if (Prime == false)
                    {
                        NB1 = NB1 + 1;
                    }
                }
            }
        }

        private void vScrollBar2_Scroll(object sender, ScrollEventArgs e)
        {
            label3.Text = vScrollBar2.Value.ToString();
        }
    }

}

推荐答案

这绝对不是一个目的标签。你真正想要使用的是一个ComboBox。
That's absolutely not the purpose of a label. What you actually want to use is a ComboBox.


这篇关于如何创建具有多个值的标签框,以及如何使其成为垂直滚动控制它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆