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


C# TableLayoutPanel.GetPositionFromControl方法代码示例

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


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

示例1: TestCellPositioning17

		public void TestCellPositioning17 ()
		{
			// ColumnCount == RowCount == 0, but control is added at > 0.
			// The columns and rows are created, but ColumnCount and RowCount remains 0
			//
			TableLayoutPanel p = new TableLayoutPanel ();
			p.ColumnCount = 0;
			p.RowCount = 0;
			Control c1 = new Button ();

			p.Controls.Add (c1, 6, 7);
			Assert.AreEqual (new TableLayoutPanelCellPosition (6, 7), p.GetPositionFromControl (c1), "C1");
			Assert.AreEqual (0, p.LayoutSettings.ColumnCount, "C2");
			Assert.AreEqual (0, p.LayoutSettings.RowCount, "C3");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:15,代码来源:TableLayoutTest.cs

示例2: TestCellPositioning18

		public void TestCellPositioning18 ()
		{
			// A control with both rowspan and columnspan > 1 was getting
			// other controls put into its extent (i.e. c3 was ending up
			// at (1,1) instead of (2,1).
			TableLayoutPanel p = new TableLayoutPanel ();
			Control c1 = new Button ();
			Control c2 = new Button ();
			Control c3 = new Button ();
			Control c4 = new Button ();

			p.ColumnCount = 3;
			p.RowCount = 4;

			p.SetRowSpan (c1, 2);
			p.SetColumnSpan (c1, 2);
			p.SetCellPosition (c1, new TableLayoutPanelCellPosition (0, 0));

			p.Controls.Add (c1);
			p.Controls.Add (c2);
			p.Controls.Add (c3);
			p.Controls.Add (c4);

			Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
			Assert.AreEqual (new TableLayoutPanelCellPosition (2, 0), p.GetPositionFromControl (c2), "C2");
			Assert.AreEqual (new TableLayoutPanelCellPosition (2, 1), p.GetPositionFromControl (c3), "C3");
			Assert.AreEqual (new TableLayoutPanelCellPosition (0, 2), p.GetPositionFromControl (c4), "C4");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:28,代码来源:TableLayoutTest.cs

示例3: TestCellPositioning15

		public void TestCellPositioning15 ()
		{
			// Column span = 2, but control is in the last column, forces control back into 1st column, next row
			// I have no clue why c3 shouldn't be in (1,0), but MS says it's not
			TableLayoutPanel p = new TableLayoutPanel ();
			Control c1 = new Button ();
			Control c2 = new Button ();
			Control c3 = new Button ();

			p.ColumnCount = 2;
			p.RowCount = 2;

			p.SetColumnSpan (c2, 2);
			p.SetCellPosition (c2, new TableLayoutPanelCellPosition (1, 0));

			p.Controls.Add (c1);
			p.Controls.Add (c2);
			p.Controls.Add (c3);

			Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
			Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c2), "C2");
			Assert.AreEqual (new TableLayoutPanelCellPosition (0, 2), p.GetPositionFromControl (c3), "C3");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:23,代码来源:TableLayoutTest.cs

示例4: TestCellPositioning16

		public void TestCellPositioning16 ()
		{
			// Row span = 2, but control is in the last row, creates new row
			TableLayoutPanel p = new TableLayoutPanel ();
			Control c1 = new Button ();
			Control c2 = new Button ();
			Control c3 = new Button ();

			p.ColumnCount = 2;
			p.RowCount = 2;

			p.SetRowSpan (c3, 2);
			p.SetCellPosition (c3, new TableLayoutPanelCellPosition (0, 1));

			p.Controls.Add (c1);
			p.Controls.Add (c2);
			p.Controls.Add (c3);

			Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
			Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c2), "C2");
			Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c3), "C3");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:22,代码来源:TableLayoutTest.cs

示例5: TestCellPositioning12

		public void TestCellPositioning12 ()
		{
			// Requesting a column greater than ColumnCount, request is ignored
			TableLayoutPanel p = new TableLayoutPanel ();
			Control c1 = new Button ();
			Control c2 = new Button ();
			Control c3 = new Button ();

			p.ColumnCount = 2;
			p.RowCount = 2;

			p.SetColumn (c1, 4);

			p.Controls.Add (c1);
			p.Controls.Add (c2);
			p.Controls.Add (c3);

			Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
			Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c2), "C2");
			Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c3), "C3");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:21,代码来源:TableLayoutTest.cs

示例6: TestCellPositioning14

		public void TestCellPositioning14 ()
		{
			// Col span = 3, fixed grow style
			TableLayoutPanel p = new TableLayoutPanel ();
			p.GrowStyle = TableLayoutPanelGrowStyle.FixedSize;
			Control c1 = new Button ();

			p.ColumnCount = 2;
			p.RowCount = 2;

			p.SetColumnSpan (c1, 3);

			p.Controls.Add (c1);

			Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:16,代码来源:TableLayoutTest.cs

示例7: TestCellPositioning9

		public void TestCellPositioning9 ()
		{
			// Row span
			TableLayoutPanel p = new TableLayoutPanel ();
			Control c1 = new Button ();
			Control c2 = new Button ();
			Control c3 = new Button ();

			p.ColumnCount = 2;
			p.RowCount = 2;

			p.SetRowSpan (c1, 2);

			p.Controls.Add (c1);
			p.Controls.Add (c2);
			p.Controls.Add (c3);

			Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
			Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c2), "C2");
			Assert.AreEqual (new TableLayoutPanelCellPosition (1, 1), p.GetPositionFromControl (c3), "C3");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:21,代码来源:TableLayoutTest.cs

示例8: TestCellPositioning7

		public void TestCellPositioning7 ()
		{
			// One control has fixed column and row
			TableLayoutPanel p = new TableLayoutPanel ();
			Control c1 = new Button ();
			Control c2 = new Button ();
			Control c3 = new Button ();
			Control c4 = new Button ();

			p.ColumnCount = 2;
			p.RowCount = 2;

			p.SetColumn (c3, 1);
			p.SetRow (c3, 1);

			p.Controls.Add (c1);
			p.Controls.Add (c2);
			p.Controls.Add (c3);
			p.Controls.Add (c4);

			Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
			Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c2), "C2");
			Assert.AreEqual (new TableLayoutPanelCellPosition (1, 1), p.GetPositionFromControl (c3), "C3");
			Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c4), "C4");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:25,代码来源:TableLayoutTest.cs

示例9: TestCellPositioning3

		public void TestCellPositioning3 ()
		{
			// Growstyle = Add Columns
			TableLayoutPanel p = new TableLayoutPanel ();
			p.GrowStyle = TableLayoutPanelGrowStyle.AddColumns;

			Control c1 = new Button ();
			Control c2 = new Button ();
			Control c3 = new Button ();
			Control c4 = new Button ();
			Control c5 = new Button ();
			Control c6 = new Button ();

			p.ColumnCount = 2;
			p.RowCount = 2;

			p.Controls.Add (c1);
			p.Controls.Add (c2);
			p.Controls.Add (c3);
			p.Controls.Add (c4);
			p.Controls.Add (c5);
			p.Controls.Add (c6);

			Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
			Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c2), "C2");
			Assert.AreEqual (new TableLayoutPanelCellPosition (2, 0), p.GetPositionFromControl (c3), "C3");
			Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c4), "C4");
			Assert.AreEqual (new TableLayoutPanelCellPosition (1, 1), p.GetPositionFromControl (c5), "C5");
			Assert.AreEqual (new TableLayoutPanelCellPosition (2, 1), p.GetPositionFromControl (c6), "C6");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:30,代码来源:TableLayoutTest.cs

示例10: TestCellPositioning

		public void TestCellPositioning ()
		{
			// Standard Add
			TableLayoutPanel p = new TableLayoutPanel ();
			Control c1 = new Button ();
			Control c2 = new Button ();
			Control c3 = new Button ();
			Control c4 = new Button ();

			p.ColumnCount = 2;
			p.RowCount = 2;

			p.Controls.Add (c1);
			p.Controls.Add (c2);
			p.Controls.Add (c3);
			p.Controls.Add (c4);

			Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
			Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c2), "C2");
			Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c3), "C3");
			Assert.AreEqual (new TableLayoutPanelCellPosition (1, 1), p.GetPositionFromControl (c4), "C4");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:22,代码来源:TableLayoutTest.cs

示例11: t_combo_SelectedIndexChanged

        void t_combo_SelectedIndexChanged(object sender, EventArgs e)
        {
            TableLayoutPanelCellPosition pos = new TableLayoutPanelCellPosition();
            Control ctr = new Control();
            Control ctrParent = new Control();
            TableLayoutPanel ctrGrandParent = new TableLayoutPanel();
            TextBox t_txtBox2 = new TextBox();

            ctr = (Control)sender; // cast combobox control
            ctrParent = ctr.Parent; // get panel control
            ctrGrandParent = (TableLayoutPanel)ctrParent.Parent; // get tablelayoutpanel control
            pos = ctrGrandParent.GetPositionFromControl(ctrParent); // get panel position

            if (ctrParent.Controls.Count < 2 & ctr.Text == "Other")
            {
                t_txtBox2.Location = new Point(3, 30);
                t_txtBox2.Text = ctr.Tag.ToString();
                ctrParent.Controls.Add(t_txtBox2);
            }
            else if (ctrParent.Controls.Count == 2 & ctr.Text != "Other")
            {
                ctrGrandParent.GetControlFromPosition(pos.Column, pos.Row).Controls.RemoveAt(1);
            }
        }
开发者ID:hcs-scheduler,项目名称:scheduler,代码行数:24,代码来源:Form1.cs


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