• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            posts - 124,  comments - 29,  trackbacks - 0
            1: 加GridLevelNode時(shí)注意加的位置!!!   不能一味的往頂層節(jié)點(diǎn)上加!
             2:一定要把新建的 view放到 viewCollection里面. this.gridControlUserTable.ViewCollection.Add(newGridView)
            3:新建的關(guān)系名一定要和新建的level保持一致!!!!
            4:注意GridView的更新(父GridView的更新)
              private void gridControlUserTable_DoubleClick(object sender, EventArgs e)
                    {
                        try
                        {
                            //gridView  datatable  GridLevelNode都用同一個(gè)名字
                            //ViewCaption中放類別, 1, 用戶相關(guān)表.  0, 用戶無(wú)關(guān)表
                            GridView curView = (DevExpress.XtraGrid.Views.Grid.GridView)gridControlUserTable.FocusedView; //當(dāng)前的GridView
                            curView.MasterRowExpanding += new MasterRowCanExpandEventHandler(curView_MasterRowExpanding);
                            curView.MasterRowExpanded += new CustomMasterRowEventHandler(curView_MasterRowExpanded);


                            string viewName = curView.Name;
                            string id = "view" + icount.ToString();
                            int ihandle = curView.FocusedRowHandle; //當(dāng)前的行號(hào)
                            DataRow dr = curView.GetDataRow(ihandle); //當(dāng)前的行


                            GridView newGridView = null;
                            DataTable newDataTable = null;
                            DevExpress.XtraGrid.GridLevelNode gridLevel = null;
                            icount++;
                            #region 頂層的gridView
                            if (curView.Name == "gridViewParent")//頂層的gridView
                            {
                                string tableEName = dr["tableEName"].ToString();
                                string supplierRelated = dr["supplierRelated"].ToString();

                                #region 頂層
                                newGridView = new GridView();
                                newGridView.Name = id;
                                newGridView.OptionsView.ShowGroupPanel = false;
                                newGridView.OptionsBehavior.Editable = false;
                                newGridView.OptionsDetail.ShowDetailTabs = false;
                                newGridView.OptionsCustomization.AllowColumnMoving = false;
                                newGridView.OptionsBehavior.AutoExpandAllGroups = true;
                                this.gridControlUserTable.ViewCollection.Add(newGridView);

                                RelatedTableRecord[] relatedTableInfoArray = null;
                                UnrelatedTableRecord[] unRelatedTableInfoArray = null;
                                if (supplierRelated == "1")//廠商相關(guān)
                                {

                                    relatedTableInfoArray = PublicFunction.GetRelatedTableInfos(tableEName, btime, etime);
                                    if (relatedTableInfoArray == null || relatedTableInfoArray.Length == 0)
                                    {
                                        return;
                                    }
                                    CollectCommon.SetGridViewColumn(newGridView, "Config\\CollectMonitor\\supplierRelatedColumn.xml", "/Head");
                                    newGridView.ViewCaption = "1";
                                }
                                else if (supplierRelated == "0")//廠商無(wú)關(guān)
                                {

                                    unRelatedTableInfoArray = PublicFunction.GetUnRelatedTableInfos(tableEName, "", btime, etime);
                                    if (unRelatedTableInfoArray == null || unRelatedTableInfoArray.Length == 0)
                                    {
                                        return;
                                    }
                                    CollectCommon.SetGridViewColumn(newGridView, "Config\\CollectMonitor\\supplierUnRelatedColumn.xml", "/Head");
                                    newGridView.ViewCaption = "0";
                                }

                                newDataTable = new DataTable(id);
                                CollectCommon.SetDataTableColumn(newGridView, newDataTable);
                                if (supplierRelated == "1")//廠商相關(guān)
                                {
                                    CollectCommon.FillTableData(newDataTable, relatedTableInfoArray);
                                }
                                else//廠商無(wú)關(guān)
                                {
                                    CollectCommon.FillTableData(newDataTable, unRelatedTableInfoArray);
                                }
                                ds.Tables.Add(newDataTable);

                                gridLevel = new DevExpress.XtraGrid.GridLevelNode();
                                gridLevel.LevelTemplate = newGridView;
                                gridLevel.RelationName = id;

                                gridControlUserTable.LevelTree.Nodes.Add(gridLevel);

                                DataRelation dataRelation = new DataRelation(id, ds.Tables["parent"].Columns["tableEName"], ds.Tables[id].Columns["tableEName"], false);
                                ds.Relations.Add(dataRelation);

                                newGridView.RefreshData();
                                gridViewParent.RefreshData();

                                #endregion
                            }
                            #endregion
                            #region 非頂層表
                            else//非頂層表
                            {
                                if (curView.ViewCaption == "1")//廠商相關(guān)表,再鉆取最后一層,廠商無(wú)關(guān)的信息表,就鉆取到頭了.
                                {
                                    #region
                                    string tableEName = dr["tableEName"].ToString();
                                    string supplier = dr["supplier"].ToString();
                                    UnrelatedTableRecord[] unRelatedTableInfoArray = null;
                                    unRelatedTableInfoArray = PublicFunction.GetUnRelatedTableInfos(tableEName, supplier, btime, etime);
                                    if (unRelatedTableInfoArray == null || unRelatedTableInfoArray.Length == 0)
                                    {
                                        return;
                                    }
                                    newGridView = new GridView();
                                    newGridView.Name = id;
                                    newGridView.OptionsView.ShowGroupPanel = false;
                                    newGridView.OptionsBehavior.Editable = false;
                                    newGridView.OptionsDetail.ShowDetailTabs = false;
                                    newGridView.OptionsCustomization.AllowColumnMoving = false;
                                    newGridView.OptionsBehavior.AutoExpandAllGroups = true;
                                    newGridView.ViewCaption = "0";
                                    this.gridControlUserTable.ViewCollection.Add(newGridView);

                                    CollectCommon.SetGridViewColumn(newGridView, "Config\\CollectMonitor\\supplierUnRelatedColumn.xml", "/Head");

                                    newDataTable = new DataTable(id);
                                    CollectCommon.SetDataTableColumn(newGridView, newDataTable);
                                    CollectCommon.FillTableData(newDataTable, unRelatedTableInfoArray);

                                    ds.Tables.Add(newDataTable);

                                    gridLevel = new DevExpress.XtraGrid.GridLevelNode();
                                    gridLevel.LevelTemplate = newGridView;
                                    gridLevel.RelationName = id;

                                    string parentTableName = curView.Name;
                                    string parentLevelName = curView.Name;

                                    //AddGridLevelNode(gridControlUserTable, parentLevelName, gridLevel);
                                    
                                    gridControlUserTable.LevelTree.Nodes[0].Nodes.Add(gridLevel);

                                    DataColumn[] parentColumns = new DataColumn[2];
                                    DataColumn[] childColumns = new DataColumn[2];
                                    parentColumns[0] = ds.Tables[parentTableName].Columns["tableEName"];
                                    parentColumns[1] = ds.Tables[parentTableName].Columns["supplier"];


                                    childColumns[0] = ds.Tables[id].Columns["tableEName"];
                                    childColumns[1] = ds.Tables[id].Columns["supplier"];

                                    DataRelation dataRelation = new DataRelation(id, parentColumns, childColumns, false);
                                    //DataRelation dataRelation = new DataRelation(id, parentColumns[0], childColumns[0], false);
                                    ds.Relations.Add(dataRelation);
                                    curView.RefreshData();
                                    
                                    #endregion
                                }
                                else if (curView.ViewCaption == "0")//廠商無(wú)關(guān)表
                                {

                                }
                            }
                            #endregion
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message + ex.StackTrace);
                        }
                    }
            posted on 2010-04-17 18:04 天書 閱讀(4382) 評(píng)論(0)  編輯 收藏 引用

            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理



            <2013年11月>
            272829303112
            3456789
            10111213141516
            17181920212223
            24252627282930
            1234567

            常用鏈接

            留言簿(5)

            隨筆檔案

            文章分類

            文章檔案

            好友的Bolg

            搜索

            •  

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            国产99久久久国产精品小说| 久久精品无码一区二区无码| 精品国产婷婷久久久| 少妇被又大又粗又爽毛片久久黑人| 久久精品亚洲男人的天堂| 亚洲va久久久噜噜噜久久狠狠| 久久久久国产精品熟女影院| 国产视频久久| 亚洲AV日韩精品久久久久久| 免费国产99久久久香蕉| 久久久久人妻一区二区三区| 久久精品国产精品青草| 亚洲色欲久久久综合网| 精品久久久久久无码国产| 中文字幕乱码久久午夜| 日韩久久久久中文字幕人妻| 久久综合久久综合久久| 无码专区久久综合久中文字幕| 久久精品国产亚洲Aⅴ蜜臀色欲| 久久丫精品国产亚洲av不卡| 伊人久久精品影院| 久久国产精品无码网站| 91麻豆精品国产91久久久久久 | 久久免费精品一区二区| 伊人久久无码中文字幕| 欧美伊人久久大香线蕉综合69| 久久精品国产91久久麻豆自制 | 精品精品国产自在久久高清| 婷婷久久久亚洲欧洲日产国码AV| 日韩十八禁一区二区久久| 久久成人精品| 久久99精品久久久久久噜噜| 国产精品免费久久久久影院 | 亚洲AV伊人久久青青草原| 国产亚洲精午夜久久久久久| 中文精品久久久久国产网址| 久久久青草久久久青草| 欧美激情精品久久久久| 一本久久久久久久| 日日狠狠久久偷偷色综合96蜜桃| 久久久久香蕉视频|