如何在c#.net windows应用程序中显示或显示标签上的百分比? [英] how to show or display percentage on label during process in c# .net windows application?

查看:87
本文介绍了如何在c#.net windows应用程序中显示或显示标签上的百分比?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我为我的Windows应用软件开发了一个启动画面,我想在显示过程中显示增量百分比,我们如何显示百分比,我的进度条样式是Marquee,我无法改变进度条样式。

这是我的启动画面代码。



  public   partial   class  SplashScreen:表格
{
委托 void StringParameterDelegate( string 文字);
// delegate void StringParameterWithStatusDelegate(string Text,TypeOfMessage tom);
< span class =code-keyword> delegate void SplashShowCloseDelegate();

/// < 摘要 >
/// 确保使用API​​关闭启动画面,而不是通过键盘或其他任何东西关闭
/// < / summary >
bool CloseSplashScreenFlag = ;
public SplashScreen()
{
InitializeComponent();
.lblProcess.Parent = ;
this .lblProcess.BackColor = Color.Transparent;
lblProcess.ForeColor = Color.Green;

// this.progressBar1.Parent = this.pictureBox1;
// this.progressBar1.BackColor = Color.Transparent;

progressBar1.Show();
}
public void ShowSplashScreen()
{
if (InvokeRequired)
{
// 我们不在UI线程中,所以我们需要调用BeginInvoke
BeginInvoke( new SplashShowCloseDelegate(ShowSplashScreen));
return ;
}
this .Show();
Application.Run( this );
}
/// < 摘要 >
/// 关闭SplashScreen
/// < / summary >
public void CloseSplashScreen()
{
if (InvokeRequired)
{
// 我们不在UI线程中,所以我们需要调用BeginInvoke
BeginInvoke( new
SplashShowCloseDelegate(CloseSplashScreen));
return ;
}
CloseSplashScreenFlag = true ;
this .Close();
}
public void UdpateStatusText( string Text)
{
if (InvokeRequired)
{
// 我们不在UI线程中,所以我们需要调用BeginInvoke
BeginInvoke( new StringParameterDelegate(UdpateStatusText), new object [] {Text} );
return ;
}
// 如果我们到目前为止,必须在UI线程上
lblProcess.ForeColor = Color.Black;
lblProcess.Text =文字;
}

}





所以,请帮助我如何用这个增加百分比样式启动画面。



在此先感谢。



Ankit Agarwal

软件工程师

解决方案

尝试 ProgressBar with Percentage [ ^ ]。

此链接可能对您有所帮助

C#.net中的进度条


Hello,

I have a developing a splash screen for my windows application software, i want to display increment percentage during process, how can we display percentage, my progress bar style is Marquee, i can not change progress bar style.
It's my code of splash screen.

public partial class SplashScreen : Form
    {
        delegate void StringParameterDelegate(string Text);
        //delegate void StringParameterWithStatusDelegate(string Text, TypeOfMessage tom);
        delegate void SplashShowCloseDelegate();

        /// <summary>
        /// To ensure splash screen is closed using the API and not by keyboard or any other things
        /// </summary>
        bool CloseSplashScreenFlag = false;
        public SplashScreen()
        {
            InitializeComponent();
            this.lblProcess.Parent = this;
            this.lblProcess.BackColor = Color.Transparent;
            lblProcess.ForeColor = Color.Green;

            //this.progressBar1.Parent = this.pictureBox1;
            //this.progressBar1.BackColor = Color.Transparent;

            progressBar1.Show();
        }
        public void ShowSplashScreen()
        {
            if (InvokeRequired)
            {
                // We're not in the UI thread, so we need to call BeginInvoke
                BeginInvoke(new SplashShowCloseDelegate(ShowSplashScreen));
                return;
            }
            this.Show();
            Application.Run(this);
        }
        /// <summary>
        /// Closes the SplashScreen
        /// </summary>
        public void CloseSplashScreen()
        {
            if (InvokeRequired)
            {
                // We're not in the UI thread, so we need to call BeginInvoke
                BeginInvoke(new SplashShowCloseDelegate(CloseSplashScreen));
                return;
            }
            CloseSplashScreenFlag = true;
            this.Close();
        }
        public void UdpateStatusText(string Text)
        {
            if (InvokeRequired)
            {
                // We're not in the UI thread, so we need to call BeginInvoke
                BeginInvoke(new StringParameterDelegate(UdpateStatusText), new object[] { Text });
                return;
            }
            // Must be on the UI thread if we've got this far
            lblProcess.ForeColor = Color.Black;
            lblProcess.Text = Text;
        }

    }



So, Please help me how can we increment percentage style with this Splash Screen.

Thanks in Advance.

Ankit Agarwal
Software Engineer

解决方案

Try ProgressBar with Percentage[^].


This link may be helpfull for you
Progress Bar in C# .net


这篇关于如何在c#.net windows应用程序中显示或显示标签上的百分比?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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