Example #1
0
        /// <summary>
        /// 配置GridView的列
        /// </summary>
        /// <param name="nameHeader">Name列模版</param>
        /// <param name="nameWidth">Name列宽度</param>
        /// <param name="listColumns">列集合</param>
        public void SetColumns(GridViewColumnHeader nameHeader, int nameWidth, List <GridViewColumn> listColumns)
        {
            GridViewColumnCollection gvcc    = (GridViewColumnCollection)mResouce["Gvcc"];
            GridViewColumn           gvcName = gvcc[0];

            gvcName.Header = nameHeader;
            gvcName.Width  = nameWidth;
            for (int i = gvcc.Count - 1; i > 0; i--)
            {
                gvcc.Remove(gvcc[i]);
            }
            for (int i = 0; i < listColumns.Count; i++)
            {
                gvcc.Add(listColumns[i]);
            }
        }
        static void UpdateListView(GridViewColumnCollection lv)
        {
            GridViewColumnCollection gridview = lv;

            if (gridview == null || gridview.Count <= 0)
            {
                return;
            }
            List <GridViewColumn> toRemove = new List <GridViewColumn>();

            foreach (GridViewColumn gc in gridview)
            {
                if (GetIsVisible(gc) == false)
                {
                    toRemove.Add(gc);
                }
            }
            foreach (GridViewColumn gc in toRemove)
            {
                gridview.Remove(gc);
            }
        }