All pastes #739419 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-10-17 04:02 UTC
rendered paste body
using System;
using System.Drawing;
using System.Globalization;
using System.Windows.Forms;
//using NUnit.Framework;

public class MainForm : Form
{
	public MainForm ()
	{
		// 
		// _tableLayoutPanel
		// 
		_tableLayoutPanel = new TableLayoutPanel ();
		_tableLayoutPanel.AutoScroll = true;
		_tableLayoutPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink;
		_tableLayoutPanel.ColumnCount = 1;
		_tableLayoutPanel.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 100F));
		_tableLayoutPanel.Dock = DockStyle.Fill;
		_tableLayoutPanel.RowCount = 5;
		_tableLayoutPanel.RowStyles.Add (new RowStyle ());
		_tableLayoutPanel.RowStyles.Add (new RowStyle ());
		_tableLayoutPanel.RowStyles.Add (new RowStyle ());
		_tableLayoutPanel.RowStyles.Add (new RowStyle ());
		_tableLayoutPanel.RowStyles.Add (new RowStyle ());
		_tableLayoutPanel.TabIndex = 0;
		//Controls.Add (_tableLayoutPanel);
		TextBox tb = new TextBox ();
		tb.Text = "é doesn't work!";
		Controls.Add (tb);
		//Controls.Add (new RichTextBox ());
		// 
		// Form2
		// 
		AutoScaleDimensions = new SizeF (6F, 13F);
		AutoScaleMode = AutoScaleMode.Font;
		ClientSize = new Size (401, 368);
		Location = new Point (250, 100);
		StartPosition = FormStartPosition.Manual;
		Text = "bug #332892";
		Load += new EventHandler (MainForm_Load);
		ResumeLayout (false);
	}

	[STAThread]
	static void Main ()
	{
		Application.EnableVisualStyles ();
		Application.SetCompatibleTextRenderingDefault (false);
		Application.Run (new MainForm ());

	}

private class MyButton : Control, IButtonControl
{
	public MyButton ()
	{
		BackColor = Color.Green;
	}

	#region IButtonControl Members

	public DialogResult DialogResult
	{
		get
		{
			return DialogResult.Cancel;
		}
		set
		{
			throw new Exception ("The method or operation is not implemented.");
		}
	}

	public void NotifyDefault (bool value)
	{
		Console.WriteLine ("Default: {0}", value);
	}

	public void PerformClick ()
	{
		throw new Exception ("The method or operation is not implemented.");
	}

	#endregion
}

	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");
	}

	void MainForm_Load (object sender, EventArgs e)
	{
		//TestCellPositioning12 ();
		//_tableLayoutPanel.GrowStyle = TableLayoutPanelGrowStyle.AddColumns;
		for (int i = 1; i <= 5; i++)
			AddButton (i);

		MyButton cb = new MyButton ();
		this.CancelButton = cb;
		cb.Size = new Size (100, 100);
		_tableLayoutPanel.Controls.Add (cb);
			
		InstructionsForm instructionsForm = new InstructionsForm ();
		instructionsForm.Show ();
		
		Console.WriteLine (_tableLayoutPanel.RowCount);
	}

	void AddButton (int row)
	{
		Button button = new Button ();
		button.Dock = DockStyle.Top;
		button.Height = 200;
		button.Text = row.ToString ();
		button.Click += new EventHandler (Button_Click);
		_tableLayoutPanel.Controls.Add (button, 0, row);
	}

	void Button_Click (object sender, EventArgs args)
	{
		((Control)sender).Visible = false;
	}

	private TableLayoutPanel _tableLayoutPanel;
}

public class InstructionsForm : Form
{
	public InstructionsForm ()
	{
		// 
		// _tabControl
		// 
		_tabControl = new TabControl ();
		_tabControl.Dock = DockStyle.Fill;
		Controls.Add (_tabControl);
		// 
		// _bugDescriptionText1
		// 
		_bugDescriptionText1 = new TextBox ();
		_bugDescriptionText1.Dock = DockStyle.Fill;
		_bugDescriptionText1.Multiline = true;
		_bugDescriptionText1.Text = string.Format (CultureInfo.InvariantCulture,
			"Expected result on start-up:{0}{0}" +
			"1. Five numbered buttons are added to the TableLayoutPanel.{0}{0}" +
			"2. The buttons are added in order.",
			Environment.NewLine);
		// 
		// _tabPage1
		// 
		_tabPage1 = new TabPage ();
		_tabPage1.Text = "#1";
		_tabPage1.Controls.Add (_bugDescriptionText1);
		_tabControl.Controls.Add (_tabPage1);
		// 
		// _bugDescriptionText2
		// 
		_bugDescriptionText2 = new TextBox ();
		_bugDescriptionText2.Dock = DockStyle.Fill;
		_bugDescriptionText2.Multiline = true;
		_bugDescriptionText2.Text = string.Format (CultureInfo.InvariantCulture,
			"Steps to execute:{0}{0}" +
			"1. Scroll down.{0}{0}" +
			"2. Click button 3.{0}{0}" +
			"3. Scroll up.{0}{0}" +
			"Expected result:{0}{0}" +
			"2. No gap is displayed between buttons 2 and 4.",
			Environment.NewLine);
		// 
		// _tabPage2
		// 
		_tabPage2 = new TabPage ();
		_tabPage2.Text = "#2";
		_tabPage2.Controls.Add (_bugDescriptionText2);
		_tabControl.Controls.Add (_tabPage2);
		// 
		// InstructionsForm
		// 
		ClientSize = new Size (300, 90);
		Location = new Point (600, 100);
		StartPosition = FormStartPosition.Manual;
		Text = "Instructions - bug #332892";
	}

	private TextBox _bugDescriptionText1;
	private TextBox _bugDescriptionText2;
	private TabControl _tabControl;
	private TabPage _tabPage1;
	private TabPage _tabPage2;
}