zoukankan      html  css  js  c++  java
  • wpf app全局变量传参方法(代码片段 )

    清空某行绑定的行数据:
    1    int RowIndex = datagrid.SelectedIndex;
    2  _Table.Rows[RowIndex]["AVERAGE_PRICE"] = DBNull.Value;
    View Code
    弹出层对象 :(用于弹出二级页面)
     1  /// 弹出层对象  
     2         public static NavigationWindow window = null;
     3         #region 使用NavigationWindow弹出页面
     4         private void ShowNavigationWindow(string title, string uri, int width, int height)
     5         {
     6             try
     7             {
     8                 window = new NavigationWindow();//创建窗体对象
     9                 window.Title = title;
    10                 window.MaxHeight = height;
    11                 window.MaxWidth = width;
    12                 window.Width = this.ActualWidth;
    13                 window.Height = this.ActualHeight;
    14                 window.WindowStyle = WindowStyle.ToolWindow;//设置边框样式
    15                 window.WindowStartupLocation = WindowStartupLocation.CenterScreen;//设置显示位置
    16                 window.ResizeMode = ResizeMode.NoResize;//设置显示
    17                 window.Source = new Uri(uri, UriKind.Relative);//设置url
    18                 window.ShowsNavigationUI = false;
    19                 window.ShowInTaskbar = false;
    20                 window.ShowDialog();
    21                 window.Close();
    22             }
    23             catch(Exception ex){
    24                 
    25             }
    26           
    27         }
    View Code
    将变量赋值给app中的全局变量
     1  string backgoodsid = ""; string backgoodscode = "";
     2             DataGridRow row = sender as DataGridRow;
     3             var cell = row.Item;
     4             DataRowView item = cell as DataRowView; 
     5             if (item != null)
     6             {
     7                 backgoodsid = item[0].ToString();
     8             }
     9             if (item != null)
    10             {
    11                 backgoodscode = item[4].ToString();
    12             }
    13             string Startdate = STARTDATE.Text;
    14             string Enddate = ENDDATE.Text;
    15             string a = StaffSearchType.Text;
    16             (Application.Current as App).BackgoodsCode = backgoodscode;
    17             (Application.Current as App).Backgoodsid = backgoodsid;
    18             (Application.Current as App).StartDate = Startdate;
    19             (Application.Current as App).EndDate = Enddate;
    20             (Application.Current as App).window = a;
    View Code
    在二级页面获取数据
     1   #region 获取数据
     2 
     3             if ((Application.Current as App).BackgoodsCode != "")
     4             {
     5                 backgoodscode = (Application.Current as App).BackgoodsCode;
     6             }
     7             if((Application.Current as App).Backgoodsid != "")
     8             {
     9                 backgoodsid= (Application.Current as App).Backgoodsid;
    10             }
    11             if ((Application.Current as App).Type != "")
    12             {
    13                 type = (Application.Current as App).Type;
    14             } 
    15             if ((Application.Current as App).StartDate != "")
    16             {
    17                 Startdate = (Application.Current as App).StartDate;
    18             }
    19             if ((Application.Current as App).EndDate != "")
    20             {
    21                 Enddate = (Application.Current as App).EndDate;
    22             }
    23             if ((Application.Current as App).window != "")
    24             {
    25                 a = (Application.Current as App).window;
    26             }
    27             #endregion
    View Code
  • 相关阅读:
    updatePanel、自定义控件、弹出提示
    防止csv和excel转义
    随机码的生成
    一个页面多个Form——ajaxform
    Google首页电吉
    Sivlerlight3 向silverlight传递自定义参数
    Java接口测试get请求,使用httpClient获取cookies+携带获取的cookies访问get接口
    Java接口测试post请求,使用httpClient获取cookies+携带获取的cookies访问post接口
    Acess定义过多字段
    无依赖Office资源的导入导出
  • 原文地址:https://www.cnblogs.com/wangzhe688/p/9323860.html
Copyright © 2011-2022 走看看