当前位置: 首页>>代码示例>>C#>>正文


C# TableLayoutPanel.GetColumnSpan方法代码示例

本文整理汇总了C#中System.Windows.Forms.TableLayoutPanel.GetColumnSpan方法的典型用法代码示例。如果您正苦于以下问题:C# TableLayoutPanel.GetColumnSpan方法的具体用法?C# TableLayoutPanel.GetColumnSpan怎么用?C# TableLayoutPanel.GetColumnSpan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.TableLayoutPanel的用法示例。


在下文中一共展示了TableLayoutPanel.GetColumnSpan方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestExtenderMethods

		public void TestExtenderMethods ()
		{
			TableLayoutPanel p = new TableLayoutPanel ();
			Control c = new Button ();

			Assert.AreEqual (new TableLayoutPanelCellPosition (-1, -1), p.GetCellPosition (c), "A1");
			Assert.AreEqual (-1, p.GetColumn (c), "A2");
			Assert.AreEqual (1, p.GetColumnSpan (c), "A3");
			Assert.AreEqual (-1, p.GetRow (c), "A4");
			Assert.AreEqual (1, p.GetRowSpan (c), "A5");

			p.SetCellPosition (c, new TableLayoutPanelCellPosition (1, 1));
			Assert.AreEqual (new TableLayoutPanelCellPosition (1, 1), p.GetCellPosition (c), "A6");

			p.SetColumn (c, 2);
			Assert.AreEqual (2, p.GetColumn (c), "A7");
			p.SetRow (c, 2);
			Assert.AreEqual (2, p.GetRow (c), "A9");

			p.SetColumnSpan (c, 2);
			Assert.AreEqual (2, p.GetColumnSpan (c), "A8");


			p.SetRowSpan (c, 2);
			Assert.AreEqual (2, p.GetRowSpan (c), "A10");

			Assert.AreEqual (new TableLayoutPanelCellPosition (2, 2), p.GetCellPosition (c), "A11");

			// ???????
			//Assert.AreEqual (new TableLayoutPanelCellPosition (-1, -1), p.GetPositionFromControl (c), "A12");
			//Assert.AreEqual (c, p.GetControlFromPosition(0, 0), "A13");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:32,代码来源:TableLayoutTest.cs

示例2: ResizeEditorControls

		/// <summary>
		/// Resizes editor controls to fit the last column
		/// </summary>
		/// <param name="tablePanel"></param>
		private static void ResizeEditorControls(TableLayoutPanel tablePanel)
		{
			tablePanel.SuspendLayout();
			try
			{
				// Make editors small
				for (int row = 0; row < tablePanel.RowCount; ++row)
				{
					Control editorControl = tablePanel.GetControlFromPosition(tablePanel.ColumnCount - 1, row);
					Option o = (editorControl != null) ? editorControl.Tag as Option : null;
					if ((o == null) || (editorControl is Label))
					{
						continue;
					}

					// Change
					editorControl.Anchor = AnchorStyles.None;
					editorControl.Width = 5;
				}

				// Layout once
				tablePanel.ResumeLayout(true);
				tablePanel.SuspendLayout();

				// Size now
				int[] colWidths = tablePanel.GetColumnWidths();
				for (int row = 0; row < tablePanel.RowCount; ++row)
				{
					Control editorControl = tablePanel.GetControlFromPosition(tablePanel.ColumnCount - 1, row);
					Option o = (editorControl != null) ? editorControl.Tag as Option : null;
					if ((o == null) || (editorControl is Label))
					{
						continue;
					}

					// Change
					int colWidth = 0;
					for (int col = 0; col < tablePanel.GetColumnSpan(editorControl); col++)
					{
						colWidth += colWidths[colWidths.Length - 1 - col];
					}
					editorControl.Width = colWidth - 10;
					editorControl.Anchor = AnchorStyles.Left | AnchorStyles.Top;
				}
			}
			finally
			{
				tablePanel.ResumeLayout(true);
			}
		}
开发者ID:stevebeauge,项目名称:crayon-syntax-snippet-wlw,代码行数:54,代码来源:FormHelper.cs


注:本文中的System.Windows.Forms.TableLayoutPanel.GetColumnSpan方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。