/// <summary> /// 自己重绘的表格,在其中放置的控件的定位 /// </summary> /// <param name="tableInfo">自定义的用于绘制表格的数据结构</param> /// <param name="controls1">需要放入的控件对象数组</param> public static void SetTableControlsPosition(structTableInfo tableInfo, Control[][] controls1) { int height = tableInfo.Height; int labWidth = Convert.ToInt32(tableInfo.EachColoumnLength[0] * tableInfo.Width) - tableInfo.BorderWidth * 4; int labHeight = tableInfo.Height / tableInfo.Rows; int offsetHeight = tableInfo.Height % tableInfo.Rows; if (controls1 != null) { int xlocaiton = 0; int ylocaiton = 0; int buttonWidth = 0; for (int i = 0; i < controls1.GetLength(0); i++) { Control[] controlsTemp = controls1[i]; buttonWidth = Convert.ToInt32(tableInfo.Width * tableInfo.EachColoumnLength[i]) - tableInfo.BorderWidth; if (i == controls1.GetLength(0) - 1) { buttonWidth = Convert.ToInt32(tableInfo.Width * tableInfo.EachColoumnLength[i]) - 2 * tableInfo.BorderWidth; } //“DX1-16”标签 WinformUILayoutHelper.SetTableControlsPosition(controlsTemp, buttonWidth, height, xlocaiton, ylocaiton, 16, 0, tableInfo.BorderWidth, false); xlocaiton = xlocaiton + tableInfo.BorderWidth + buttonWidth; } } }
/// <summary> /// 自行绘制一个表格 /// </summary> public static void DrawTableBorder(Graphics g, structTableInfo tableInfo) { DrawTableBorder(g, tableInfo.StartLocationX, tableInfo.StartLocationY, tableInfo.Width, tableInfo.Height, tableInfo.Rows, tableInfo.Columns, tableInfo.EachColoumnLength, tableInfo.EachRowHeight, tableInfo.BorderWidth, tableInfo.BorderColor); }