2017-09-29 18 views
0

我正在开发使用C#的winform应用程序,我需要简化。所以请帮助我如何在我的代码下面使用Simplfy。我在下面给出了使用代码。简化我的C#代码的任何可能性?

try 
     { 
      object countnew = ((DataTable)grid_cheque.DataSource).Compute("Count(ChequeStatus)", "ChequeStatus = 'New'"); 
      object countIssued = ((DataTable)grid_cheque.DataSource).Compute("Count(ChequeStatus)", "ChequeStatus = 'Issued'"); 
      object countCancelled = ((DataTable)grid_cheque.DataSource).Compute("Count(ChequeStatus)", "ChequeStatus = 'Cancelled'"); 
      object countDishonour = ((DataTable)grid_cheque.DataSource).Compute("Count(ChequeStatus)", "ChequeStatus = 'DisHonour'"); 

      this.lblNew.Text = ERPModule.isnull(Convert.ToString(countnew), "0"); 
      this.lbl_Issued.Text = ERPModule.isnull(Convert.ToString(countIssued), "0"); 
      this.lblCancel.Text = ERPModule.isnull(Convert.ToString(countCancelled), "0"); 
      this.lbldishonour.Text = ERPModule.isnull(Convert.ToString(countDishonour), "0"); 
     } 
     catch (Exception ex) 
     { 

     } 
+0

水晶球说默认属性是问题,这个代码在每次使用它时创建一个新的Form对象时都不起作用。解决方法是auto frm = Accounts ... Default; frm.Show(); frm.BringToFront(); –

回答

0

基于答案:

How can I bring my application window to the front?

Control.BringToFront会带来控制的主机控制的前面,比如你可能在前面带一个TextBox标签以确保标签的空白不会遮挡部分文本框。表单从Control继承了此功能,并且它可以用于在Form是MDI子级时更改Form的z顺序 - 即表单托管在另一个Form中。它不会在另一个应用程序前面显示表单。