[DEVEXPRESS/WINFORM] RepositoryItemProgressBar 클래스 : CustomDisplayText 이벤트를 사용해 커스텀 디스플레이 텍스트 설정하기
DevExpress/WinForm 2021. 12. 25. 02:03728x90
반응형
728x170
▶ MainForm.cs
using System;
using System.Drawing;
using System.Threading;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
namespace TestProject
{
/// <summary>
/// 메인 폼
/// </summary>
public partial class MainForm : Form
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainForm()
/// <summary>
/// 생성자
/// </summary>
public MainForm()
{
InitializeComponent();
this.progressBarControl.Properties.ShowTitle = true;
this.progressBarControl.Properties.PercentView = false;
this.progressBarControl.Properties.Appearance.Font = new Font("나눔고딕코딩", 12f);
this.progressBarControl.Properties.CustomDisplayText += progressBarControl_CustomDisplayText;
this.testButton.Click += testButton_Click;
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 진행바 컨트롤 커스텀 디스플레이 텍스트 설정하기 - repositoryItemProgressBar_CustomDisplayText(sender, e)
/// <summary>
/// 진행바 컨트롤 커스텀 디스플레이 텍스트 설정하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void progressBarControl_CustomDisplayText(object sender, CustomDisplayTextEventArgs e)
{
ProgressBarControl progressBarControl = sender as ProgressBarControl;
e.DisplayText = $"{e.Value} / {progressBarControl.Properties.Maximum}";
}
#endregion
#region 테스트 버튼 클릭시 처리하기 - testButton_Click(sender, e)
/// <summary>
/// 테스트 버튼 클릭시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void testButton_Click(object sender, EventArgs e)
{
this.progressBarControl.Properties.Minimum = 0;
this.progressBarControl.Properties.Maximum = 100;
this.progressBarControl.EditValue = 0;
for(int i = 1; i < 101; i++)
{
this.progressBarControl.EditValue = i;
this.progressBarControl.Update();
Thread.Sleep(50);
}
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
댓글을 달아 주세요