/// <summary> /// 表切换 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tvSingleTableList_AfterSelect(object sender, TreeViewEventArgs e) { try { _layoutRow = -1; _layoutColumn = -1; tabPageDetail.Controls.Clear(); propertyGrid1.SelectedObject = null; //取得表名 this.TableName = e.Node.Name; tabPageDetail.Text = "表 " + this.TableName + " 界面设计"; DtStruct = _bll.GetTableInformation(this.TableName).Tables[0]; _model = _bll.GetModel(e.Node.Name); //_model.DETAIL_FORM_XML = XDocument.Load(Application.StartupPath + "\\DetailForm.xml").ToString(); //按照自定义配置布局控件 if (!string.IsNullOrEmpty(_model.DETAIL_FORM_XML)) { XDocument xDoc = XDocument.Parse(_model.DETAIL_FORM_XML, LoadOptions.None); ////Linq to XML //IEnumerable<XNode> xNodes = from nd in xDoc.Root.Nodes() select nd; //Lambda IEnumerable <XElement> xElements = xDoc.Root.Elements().Select(el => el); foreach (XElement item in xElements) { CreatStimControl(item); } } //系统自动有序布局控件 else { foreach (DataRow row in DtStruct.Rows) { _layoutColumn++; //3表示显示3列 if (_layoutColumn % 3 == 0) { _layoutColumn = 0; _layoutRow++; } CreatStimControl(row); } } } catch (Exception ex) { } }
private void FrmDataView_Load(object sender, EventArgs e) { //表结构 DtStruct = _bll.GetTableInformation(TableName).Tables[0]; _model = _bll.GetModel(TableName); foreach (DataRow row in DtStruct.Rows) { if (row["ISPK"].ToString().Equals("Y")) { PkList.Add((string)row["Column_Name".ToUpper()]); } } //_model.DATAGRIDVIEW_XML = XDocument.Load(Application.StartupPath + "\\DetailForm.xml").ToString(); //按照自定义配置布局控件 if (_model != null && !string.IsNullOrEmpty(_model.DETAIL_FORM_XML)) { XDocument xDoc = XDocument.Parse(_model.DETAIL_FORM_XML, LoadOptions.None); //Lambda IEnumerable <XElement> xElements = xDoc.Root.Elements().Select(el => el); int _layoutRow = -1; // 表单布局 行 int _layoutColumn = -1; // 表单布局 列 foreach (XElement item in xElements) { string ListConditionFlag = item.Attribute("ListConditionFlag").Value; string ListShowFlag = item.Attribute("ListShowFlag").Value; var dgvCol = new DataGridViewTextBoxColumn { Name = (string)item.Attribute("Column_Name"), HeaderText = (string)item.Element("Lable").Value.TrimEnd(':').TrimEnd(':'), DataPropertyName = (string)item.Attribute("Column_Name"), Visible = ListShowFlag.Equals("True"), }; dgvData.Columns.Add(dgvCol); if (ListConditionFlag.Equals("True")) { CreateStimControl stimControl = new CreateStimControl(item, null, "add"); _layoutColumn++; //3表示显示3列 if (_layoutColumn % 3 == 0) { _layoutColumn = 0; _layoutRow++; } stimControl.AutoStimControl.Location = new Point(20 + _layoutColumn * 300, 20 + _layoutRow * 35); GrpflPanelSearch.Controls.Add(stimControl.AutoStimControl); stimControl.AutoStimControl.Visible = true; stimControl.AutoStimControl.DataFile.Enabled = true; } } //grpSearch.Height = (_layoutRow +1)* 35 + 20; } //系统自动有序布局控件 else { foreach (DataRow row in DtStruct.Rows) { var dgvCol = new DataGridViewTextBoxColumn { Name = (string)row["Column_Name".ToUpper()], HeaderText = (string)row["Column_Name".ToUpper()], DataPropertyName = (string)row["Column_Name".ToUpper()], ReadOnly = true, //主键 //Tag = row["ISPK"].ToString().Equals("Y") ? "ISPK" : "" }; dgvData.Columns.Add(dgvCol); //if (row["ISPK"].ToString().Equals("Y")) //{ // PkList.Add(dgvCol.Name); //} } } //LoadData(); }