ucResPlan.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using System.Collections;
  3. using System.Windows.Forms;
  4. using Infragistics.Win;
  5. using Infragistics.Win.UltraWinGrid;
  6. using CoreFS.CA06;
  7. namespace Core.StlMes.Client.LgCommon
  8. {
  9. public partial class ucResPlan : ucResBase
  10. {
  11. public ucResPlan()
  12. {
  13. InitializeComponent();
  14. ClsControlPack.SetUltraGridStyle(ultraGrid1, 2); //设置样式
  15. }
  16. private void ultraGrid1_KeyPress(object sender, KeyPressEventArgs e)
  17. {
  18. string strKey = this.ultraGrid1.ActiveCell.Column.ToString();
  19. if (strKey == "POTNO" || strKey == "POTAGE")
  20. {
  21. if (!(Char.IsNumber(e.KeyChar) && ultraGrid1.ActiveRow.Cells[strKey].Value.ToString().Length <= 3) && e.KeyChar != '\b')
  22. {
  23. e.Handled = true;
  24. }
  25. }
  26. }
  27. protected override void ultraGrid1_ClickCellButton(object sender, CellEventArgs e)
  28. {
  29. base.ultraGrid1_ClickCellButton(sender, e);
  30. try
  31. {
  32. if (!e.Cell.Column.Hidden && e.Cell.Column.CellActivation == Activation.AllowEdit)
  33. {
  34. if (e.Cell.Column.DataType != typeof(DateTime))
  35. {
  36. frmInputDecimal frm = new frmInputDecimal(Convert.ToString(e.Cell.Text));
  37. frm.Location = ClsControlPack.GetChildWindowLocation(frm.Size);
  38. if (frm.ShowDialog() == DialogResult.OK)
  39. {
  40. if (!frm.ValueChanged) return;
  41. e.Cell.Value = frm.Value;
  42. ultraGrid1.UpdateData();
  43. }
  44. }
  45. }
  46. }
  47. catch { }
  48. }
  49. }
  50. }