Académique Documents
Professionnel Documents
Culture Documents
1 progressBar : Bar
1 Label : lblProgress
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
namespace MyControl1
{
public partial class MyProgress : UserControl
{
public MyProgress()
{
InitializeComponent();
}
// Tao cac properties moi cho doi tuong thuoc MyProgress
public int Value
{
get { return Bar.Value; }
set
{
Bar.Value = value;
UpdateLabel();
}
}
public int Maximum
{
get { return Bar.Maximum; }
set { Bar.Maximum = value; }
}
public int Step
{
get { return Bar.Step; }
set { Bar.Step = value; }
}
// Tao cac methods
public void PerformStep()
{
Bar.PerformStep();
UpdateLabel();
}
public void UpdateLabel()
{
decimal d=(Math.Round((decimal)(Bar.Value*100)/Bar.Maximum));
lblProgress.Text = d.ToString();
lblProgress.Text += " % Done";
}
}
}
D:\MyControls\ProgressControl>cd D:\MyControls\MyControl1
D:\MyControls\MyControl1>sn -k MyControl1.snk
D:\MyControls\MyControl1>cd bin\debug
D:\MyControls\MyControl1\bin\Debug>gacutil -i MyControl1.dll
Microsoft (R) .NET Global Assembly Cache Utility. Version 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
D:\MyControls\MyControl1\bin\Debug>
5. Dung regedit tao chi dan den Mycontrol1
6. Tao windows application dung MyControl1
Tham chieu den MyControl1
Dua MyControl1 vao trong toolbox
7. Tao form
8. Viet lenh de su dung MyControl1