Windows 양식을 사용하고 양식 내에 두 개의 레이블이있는 사용자 정의 컨트롤이 있습니다. 하나는 메시지를 입력하고 다른 하나는 사용자가 입력 한 값을 넣는 것입니다. ATM에 갈 때와 같이) 번호를 표시하기 시작합니다. 사용자 정의 컨트롤에 다른 컨트롤이 없다면 제대로 작동합니다.하지만 버튼이 작동하지 않으면 버튼을 추가해도 숫자가 표시되지 않습니다. 내 숫자 키패드를 사용 ..하지만 내가 어떤 버튼을 제거하면 다시 작동합니다 ... 여기에 내 사용자 정의 컨트롤 코드입니다. 지금은 포커스가 이벤트의 키를받을 수 있기 때문에단추 또는 링크 나누기 양식 추가
public partial class OperationAmount : UserControl
{
public OperationAmount()
{
InitializeComponent();
}
private int _inputNumber = 0;
private void OperationAmount_Load(object sender, EventArgs e)
{
}
private void Form_KeyAmountPressed(object sender, KeyPressEventArgs e)
{
if (!Char.IsNumber(e.KeyChar))
{
return;
}
else if (lblOperationAmount.Text.Length > 9)
{
return;
}
else
{
_inputNumber = 10 * _inputNumber + Int32.Parse(e.KeyChar.ToString());
ReformatOutput();
}
}
private void ReformatOutput()
{
lblOperationAmount.Text = String.Format("{0:0.00}", (double)_inputNumber/100.0);
}
}