zoukankan      html  css  js  c++  java
  • 给DataGrid设置中文列名

    很多东西,由不知道,到看到,到调试好,经历了太多的搜索,测试,修改,我怕我遗忘,暂记于此。
      方法一:
     //调用 
     
    private void  InsertNull()
      
    {
       
    try
       
    {
           ………………
        DataTable Dtab 
    = myDs.Tables[0];
        
        dataGrid1.DataSource 
    =Dtab;

        
    // 把数字值替换成字符串显示
        ChangeSomeView(Dtab);

        
    //设定列名 中文显示
        SetHeaderName(Dtab.TableName);   //处理难点  tablename必须对应才能显示出中文列名
     
      }

       
    catch (Exception err)
       
    {
        MessageBox.Show(
    this,err.Message,"",MessageBoxButtons.OK,MessageBoxIcon.Error);
       }

      
      }

       
    /**中文列名****/
     
      
    /***设置表头***/
     
    方法二:select ID as 顺序号 ,cstr(Type) as  类型     ……  完成列名显示中文的功能。
     
    另外的一个小技巧 :select ID ,cstr(Type) as Type   将Type 由INT  提取的时候cstr,然后才能完成替换后的回写 
    /// <summary>
      
    /// 把数字值替换成字符串显示  1---学生表     
      
    /// </summary> 
      
    /// <param name="Dtab">DataTable Dtab</param>

      private void ChangeSomeView(DataTable Dtab)
      
    {
       
    foreach(DataRow Row in Dtab.Rows)
       
    {
        
    object IDType=Row[1];
        
    string operStr=IDType.ToString();
        
    switch(operStr)       
        
    {         
         
    case   "1"  : 
          Row[
    1]  = "学生表"  ;
          
    break;
      ……    }

       }

      }
     
  • 相关阅读:
    ipandao markdown mathjax版本
    我们是不是太关注于语法而忽略了算法
    SVGG.JS 入门教程
    关于ipandao编辑器手机访问换行问题
    启明星采购系统新版发布
    仿MSDN的帮助系统
    十分钟打造一款在线的数学公式编辑器
    Search Filter Syntax
    从华为养猪说起,聊聊我对中国计算机发展的一个遗憾-为何我们没有开发出自己的编程语言
    从.NET看微软的焦虑
  • 原文地址:https://www.cnblogs.com/flashicp/p/697065.html
Copyright © 2011-2022 走看看