伊莉討論區
標題:
winform的Keypress的問題
[打印本頁]
作者:
tw00167789
時間:
2017-7-13 03:19 AM
標題:
winform的Keypress的問題
各位大大好:
我有一個winform 出貨單, 其中有個TextBox是廠商代號, 我想要在這個欄位中如輸入"?"問號(使用KeyPress), 則會跳出搜尋廠商的對話框, 找到資料後, 關閉對話框, 把找到的廠商代號填入原表單的TextBox中, 但不知為何, TextBox都會出現一個"?"號, 我有試過用其他字元, 也都會有這種狀況, 請問有那位大大知道如何解決嗎?
private void txtSupplierNumber_KeyPress(object sender, KeyPressEventArgs e)
{
//捕捉?號
if (e.KeyChar == '?')
{
GetSupplierData();
}
}
複製代碼
private void GetSupplierData()
{
frmQrySupplier frm = new UI.frmQrySupplier();
//問啟搜尋廠商資料對話框
if (frm.ShowDialog() == DialogResult.OK)
{
Supplier supplier = SupplierBLL.GetById(frm.SearchId);
if (supplier != null)
{
//如果找到資料, 則將廠商代碼,名稱,地址輸入到各欄位
lblSupplierName.Text = supplier.Name;
txtShipAddress.Text = supplier.Address;
txtSupplierNumber.Text = supplier.Number;
}
}
}
複製代碼
找到資料後, 結果txtSupplierNumber這個TextBox就是會多一個問號
[attach]119483254[/attach]
作者:
tw00167789
時間:
2017-7-13 07:54 AM
已解決了
private void txtSupplierNumber_KeyPress(object sender, KeyPressEventArgs e)
{
//捕捉?號
if (e.KeyChar == '?')
{
//禁止輸入
e.Handled = true;
GetSupplierData();
}
}
複製代碼
歡迎光臨 伊莉討論區 (http://s03.p02.eyny.com/)
Powered by Discuz!