private void DataModelProperty_Load(object sender, EventArgs e) { CurrentDataModel = DataBlockModel.CreateNewInstance(); DataTable dt = new DataTable(); dt.Columns.Add("value", typeof(int)); dt.Columns.Add("display", typeof(string)); foreach (var item in PrintDatas.PrintFieldBM) { dt.Rows.Add(item.ID, item.PrintName); } cb_DataName.DataSource = dt; cb_DataName.DisplayMember = "display"; cb_DataName.ValueMember = "value"; }
public void AddDataControls(DataBlockTemplateModel templateModel) { CurrentTemplateModel = templateModel; RemoveAllDataBlockControls(); PaddingLeft = templateModel.PaddingLeft; PaddingTop = templateModel.PaddingTop; PaddingRight = templateModel.PaddingRight; PaddingBottom = templateModel.PaddingBottom; ColumnNum = templateModel.ColumnNum; PageWidth = templateModel.PageWidth; int width = this.pn_Area.Width / ColumnNum; for (int i = 0; i < ColumnNum; i++) { DataBlockModel newDataBlockModel = PrintDatas.dataBlockMList.Find(m => m.TemplateModelID == templateModel.ModelID && m.Index == i); if (newDataBlockModel == null) { newDataBlockModel = DataBlockModel.CreateNewInstance(); PrintDatas.dataBlockMList.Add(newDataBlockModel); newDataBlockModel.ColumnWidth = (int)(width / Percentage); newDataBlockModel.Index = i; newDataBlockModel.TemplateModelID = templateModel.ModelID; } DataBlockControl dc = new DataBlockControl(Percentage, newDataBlockModel, false); dc.Dock = DockStyle.Left; dc.DataSelectedEvent += Dc_DataSelectedEvent; dataControls.Add(dc); this.pn_Area.Controls.Add(dc); dc.BringToFront(); } dataControls[dataControls.Count - 1].Dock = DockStyle.Fill; FontFamilyName = templateModel.FontFamilyName; FontSize = templateModel.FontSize; Distance = templateModel.Distance; LineWidth = templateModel.LineWidth; }