简体   繁体   中英

How to accept only numeric value in XtraInputBox and how can I check which button has been clicked?

I have this code that fire on click of button:

private void btnDown_Click(object sender, EventArgs e)
{
    XtraInputBoxArgs args = new XtraInputBoxArgs();
    args.Caption = "Quantité";
    args.Prompt = "Entrez la quantité";
    args.DefaultButtonIndex = 0;
    args.DefaultResponse = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Quantité Restante");
    var result= XtraInputBox.Show(args);
}

I want to accept numeric value and backspace (prevent user from entring letters and special charcters in TextEdit).
How can I check which button has been clicked?

i get the solution from Dmitry Tor(DevExpress Support)

        private void button1_Click(object sender, EventArgs e)
    {
        TextEdit textEdit = new TextEdit();
        textEdit.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric;

        XtraInputBoxArgs args = new XtraInputBoxArgs();
        args.Caption = "Quantité";
        args.Prompt = "Entrez la quantité";
        args.DefaultButtonIndex = 0;
        args.DefaultResponse = "Test"; 
        args.Editor = textEdit;

        var result =  XtraInputBox.Show(args);
        if (result != null)
            MessageBox.Show("Ok button pressed");
        else
            MessageBox.Show("Cancel button pressed");
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM