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


C# DataGridPoker.CreateColumns方法代码示例

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


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

示例1: InitializePager

		public void InitializePager ()
		{
			DataGridPoker p = new DataGridPoker ();
			PagedDataSource paged = new PagedDataSource ();
			DataTable table = new DataTable ();
			DataGridItem item = new DataGridItem (-1, -1, ListItemType.Pager);
			ArrayList columns;
			LinkButton next;
			LinkButton prev;

			table.Columns.Add (new DataColumn ("one", typeof (string)));
			table.Columns.Add (new DataColumn ("two", typeof (string)));
			table.Columns.Add (new DataColumn ("three", typeof (string)));

			for (int i = 0; i < 25; i++)
				table.Rows.Add (new object [] { "1", "2", "3" });
			paged.DataSource = new DataView (table);

			columns = p.CreateColumns (paged, true);
			p.InitPager (item, columns.Count, paged);

			//
			// No where to go
			//

			Assert.AreEqual (item.Controls.Count, 1, "A1");
			Assert.AreEqual (item.Controls [0].GetType (), typeof (TableCell), "A2");
			Assert.AreEqual (item.Controls [0].Controls.Count, 3, "A3");
			Assert.AreEqual (item.Controls [0].Controls [0].GetType (), typeof (Label), "A4");
			Assert.AreEqual (item.Controls [0].Controls [1].GetType (),
					typeof (LiteralControl), "A5");
			Assert.AreEqual (item.Controls [0].Controls [2].GetType (), typeof (Label), "A6");
			Assert.AreEqual (((Label) item.Controls [0].Controls [0]).Text, "&lt;", "A7");
			Assert.AreEqual (((LiteralControl) item.Controls [0].Controls [1]).Text,
					"&nbsp;", "A7");
			Assert.AreEqual (((Label) item.Controls [0].Controls [2]).Text, "&gt;", "A8");

			//
			// Next
			//

			item = new DataGridItem (-1, -1, ListItemType.Pager);
			paged.PageSize = 5;
			paged.VirtualCount = 25;
			paged.AllowPaging = true;
			p.InitPager (item, columns.Count, paged);

			Assert.AreEqual (item.Controls.Count, 1, "A9");
			Assert.AreEqual (item.Controls [0].GetType (), typeof (TableCell), "A10");
			Assert.AreEqual (item.Controls [0].Controls.Count, 3, "A11");
			Assert.AreEqual (item.Controls [0].Controls [0].GetType (), typeof (Label), "A12");
			Assert.AreEqual (item.Controls [0].Controls [1].GetType (),
					typeof (LiteralControl), "A13");
			Assert.AreEqual (((Label) item.Controls [0].Controls [0]).Text, "&lt;", "A14");
			Assert.AreEqual (((LiteralControl) item.Controls [0].Controls [1]).Text,
					"&nbsp;", "A16");

			next = (LinkButton) item.Controls [0].Controls [2];
			Assert.AreEqual (next.Text, "&gt;", "A17");
			Assert.AreEqual (next.CommandName, "Page", "A18");
			Assert.AreEqual (next.CommandArgument, "Next", "A19");


			//
			// Both
			//

			item = new DataGridItem (-1, -1, ListItemType.Pager);
			paged.PageSize = 5;
			paged.VirtualCount = 25;
			paged.AllowPaging = true;
			paged.CurrentPageIndex = 2;
			p.InitPager (item, columns.Count, paged);

			Assert.AreEqual (item.Controls.Count, 1, "A20");
			Assert.AreEqual (item.Controls [0].GetType (), typeof (TableCell), "A21");
			Assert.AreEqual (item.Controls [0].Controls.Count, 3, "A22");
			Assert.AreEqual (item.Controls [0].Controls [1].GetType (),
					typeof (LiteralControl), "A23");
			Assert.AreEqual (((LiteralControl) item.Controls [0].Controls [1]).Text,
					"&nbsp;", "A24");

			// This is failing with an invalidcast right now. It's something related to
			// the pager thinking that it's on the last page and rendering a label instead
			next = (LinkButton) item.Controls [0].Controls [2];
			Assert.AreEqual (next.Text, "&gt;", "A25");
			Assert.AreEqual (next.CommandName, "Page", "A26");
			Assert.AreEqual (next.CommandArgument, "Next", "A27");

			prev = (LinkButton) item.Controls [0].Controls [0];
			Assert.AreEqual (prev.Text, "&lt;", "A28");
			Assert.AreEqual (prev.CommandName, "Page", "A29");
			Assert.AreEqual (prev.CommandArgument, "Prev", "A30");

			//
			// Back only
			//

			item = new DataGridItem (-1, -1, ListItemType.Pager);
			paged.PageSize = 5;
//.........这里部分代码省略.........
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:101,代码来源:DataGridTest.cs

示例2: SaveViewState

		public void SaveViewState ()
		{
			DataGridPoker p = new DataGridPoker ();

			p.TrackState ();

			object [] vs = (object []) p.SaveState ();
			Assert.AreEqual (vs.Length, 11, "A1");

			// By default the viewstate is all null
			for (int i = 0; i < vs.Length; i++)
				Assert.IsNull (vs [i], "A2-" + i);

			//
			// TODO: What goes in the [1] and [9] slots?
			//

			p.AllowPaging = true;
			vs = (object []) p.SaveState ();
			Assert.IsNotNull (vs [0], "A3");

			/*
			  This test doesn't work right now. It must be an issue
			  in the DataGridPagerStyle
			  
			p.PagerStyle.Visible = true;
			vs = (object []) p.SaveState ();
			Assert.IsNotNull (vs [2], "A5");
			*/
			
			p.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
			vs = (object []) p.SaveState ();
			Assert.IsNotNull (vs [3], "A6");

			p.FooterStyle.HorizontalAlign = HorizontalAlign.Center;
			vs = (object []) p.SaveState ();
			Assert.IsNotNull (vs [4], "A7");

			p.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
			vs = (object []) p.SaveState ();
			Assert.IsNotNull (vs [5], "A8");

			p.AlternatingItemStyle.HorizontalAlign = HorizontalAlign.Center;
			vs = (object []) p.SaveState ();
			Assert.IsNotNull (vs [6], "A9");

			p.SelectedItemStyle.HorizontalAlign = HorizontalAlign.Center;
			vs = (object []) p.SaveState ();
			Assert.IsNotNull (vs [7], "A10");

			p.EditItemStyle.HorizontalAlign = HorizontalAlign.Center;
			vs = (object []) p.SaveState ();
			Assert.IsNotNull (vs [8], "A11");

			PagedDataSource source = new PagedDataSource ();
			DataTable table = new DataTable ();
			ArrayList columns;

			table.Columns.Add (new DataColumn ("one", typeof (string)));
			table.Columns.Add (new DataColumn ("two", typeof (string)));
			table.Columns.Add (new DataColumn ("three", typeof (string)));
			source.DataSource = new DataView (table);
			columns = p.CreateColumns (source, true);

			vs = (object []) p.SaveState ();
			Assert.IsNull (vs [9], "A12");
			p.BackImageUrl = "foobar url";
			vs = (object []) p.SaveState ();
			Assert.IsNotNull (vs [9], "A12");

			Assert.IsNotNull (vs [10], "A12");
			Assert.AreEqual (vs [10].GetType (), typeof (object []), "A12");

			object [] cols = (object []) vs [10];
			Assert.AreEqual (cols.Length, 3, "A13");
		}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:76,代码来源:DataGridTest.cs

示例3: DataBindingCustomElement

		public void DataBindingCustomElement ()
		{
			DataGridPoker p = new DataGridPoker ();
			p.DataKeyField = "CustomName";
			PagedDataSource source = new PagedDataSource ();
			MyEnumerable myenum = new MyEnumerable ();
			myenum.Item = new Custom ();
			source.DataSource = myenum;
			ArrayList columns = p.CreateColumns (source, true);
			Assert.AreEqual (1, columns.Count, "A1");
			Assert.AreEqual ("CustomName", ((DataGridColumn) columns [0]).HeaderText, "A2");
			Assert.AreEqual (0, p.DataKeys.Count, "A3");
		}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:13,代码来源:DataGridTest.cs

示例4: DataBindingEnumerator

		public void DataBindingEnumerator ()
		{
			DataGridPoker p = new DataGridPoker ();
			PagedDataSource source = new PagedDataSource ();
			ArrayList list = new ArrayList ();
			ArrayList columns;
			
			list.Add ("One");
			list.Add ("Two");
			list.Add ("Three");

			AmazingEnumerable amazing = new AmazingEnumerable (list);
			source.DataSource = amazing;
			columns = p.CreateColumns (source, true);
			Assert.AreEqual (1, columns.Count, "A1");
			Assert.AreEqual ("Item", ((DataGridColumn) columns [0]).HeaderText, "A2");
			Assert.AreEqual (1, amazing.CallCount, "A3");
			Assert.AreEqual (0, p.DataKeys.Count, "A4");
		}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:19,代码来源:DataGridTest.cs

示例5: CreateSimpleColumns

		public void CreateSimpleColumns ()
		{
			DataGridPoker p = new DataGridPoker ();
			PagedDataSource source = new PagedDataSource ();
			ArrayList list = new ArrayList ();
			ArrayList columns;
			
			list.Add ("One");
			list.Add ("Two");
			list.Add ("Three");

			source.DataSource = list;
			columns = p.CreateColumns (source, true);
			Assert.AreEqual (1, columns.Count, "A1");
			Assert.AreEqual ("Item", ((DataGridColumn) columns [0]).HeaderText, "A2");

			AmazingEnumerable amazing = new AmazingEnumerable (list);

			source.DataSource = amazing;
			columns = p.CreateColumns (source, true);
			Assert.AreEqual (1, columns.Count, "A3");

			BoundColumn one = (BoundColumn) columns [0];

			Assert.AreEqual ("Item", one.HeaderText, "A4");

			// I guess this makes it bind to itself ?
			Assert.AreEqual (BoundColumn.thisExpr, one.DataField, "A5"); 

			Assert.AreEqual (String.Empty, one.DataFormatString, "A6");
			Assert.AreEqual ("Item", one.SortExpression, "A7");
			Assert.AreEqual (String.Empty, one.HeaderImageUrl, "A8");
			Assert.AreEqual (String.Empty, one.FooterText, "A9");
			Assert.AreEqual ("Item", one.HeaderText, "A10");

			source.DataSource = new ArrayList ();
			columns = p.CreateColumns (source, true);
			Assert.AreEqual (0, columns.Count, "A11");
		}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:39,代码来源:DataGridTest.cs

示例6: CreateColumnsBinding

		public void CreateColumnsBinding ()
		{
			DataGridPoker p = new DataGridPoker ();
			PagedDataSource source = new PagedDataSource ();
			DataTable table = new DataTable ();
			ArrayList columns;

			table.Columns.Add (new DataColumn ("one", typeof (string)));
			table.Columns.Add (new DataColumn ("two", typeof (string)));
			table.Columns.Add (new DataColumn ("three", typeof (string)));

			source.DataSource = new DataView (table);

			columns = p.CreateColumns (source, true);
			Assert.AreEqual (columns.Count, 3, "A1");
			Assert.AreEqual (((DataGridColumn) columns [0]).HeaderText, "one", "A2");
			Assert.AreEqual (((DataGridColumn) columns [1]).HeaderText, "two", "A3");
			Assert.AreEqual (((DataGridColumn) columns [2]).HeaderText, "three", "A4");

			table.Columns.Add (new DataColumn ("four", typeof (string)));
			table.Columns.Add (new DataColumn ("five", typeof (string)));
			table.Columns.Add (new DataColumn ("six", typeof (string)));

			// Just gets the old columns
			columns = p.CreateColumns (source, false);
			Assert.AreEqual (columns.Count, 3, "A5");
			Assert.AreEqual (((DataGridColumn) columns [0]).HeaderText, "one", "A6");
			Assert.AreEqual (((DataGridColumn) columns [1]).HeaderText, "two", "A7");
			Assert.AreEqual (((DataGridColumn) columns [2]).HeaderText, "three", "A8");

			columns = p.CreateColumns (source, true);
			Assert.AreEqual (columns.Count, 6, "A9");
			Assert.AreEqual (((DataGridColumn) columns [0]).HeaderText, "one", "A10");
			Assert.AreEqual (((DataGridColumn) columns [1]).HeaderText, "two", "A11");
			Assert.AreEqual (((DataGridColumn) columns [2]).HeaderText, "three", "A12");
			Assert.AreEqual (((DataGridColumn) columns [3]).HeaderText, "four", "A13");
			Assert.AreEqual (((DataGridColumn) columns [4]).HeaderText, "five", "A14");
			Assert.AreEqual (((DataGridColumn) columns [5]).HeaderText, "six", "A15");

			// Assigned properties of the newly created columns
			BoundColumn one = (BoundColumn) columns [0];

			Assert.AreEqual (one.HeaderText, "one", "A16");
			Assert.AreEqual (one.DataField, "one", "A17");
			Assert.AreEqual (one.DataFormatString, String.Empty, "A18");
			Assert.AreEqual (one.SortExpression, "one", "A19");
			Assert.AreEqual (one.HeaderImageUrl, String.Empty, "A20");
			Assert.AreEqual (one.FooterText, String.Empty, "A21");
		}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:49,代码来源:DataGridTest.cs

示例7: CreateColumnSet

		public void CreateColumnSet ()
		{
			DataGridPoker p = new DataGridPoker ();
			PagedDataSource source = new PagedDataSource ();
			DataTable table = new DataTable ();
			ArrayList columns;

			table.Columns.Add (new DataColumn ("one", typeof (string)));
			table.Columns.Add (new DataColumn ("two", typeof (string)));
			table.Columns.Add (new DataColumn ("three", typeof (string)));

			source.DataSource = new DataView (table);

			columns = p.CreateColumns (source, true);
			Assert.AreEqual (columns.Count, 3, "A1");
			Assert.AreEqual (((DataGridColumn) columns [0]).HeaderText, "one", "A2");
			Assert.AreEqual (((DataGridColumn) columns [1]).HeaderText, "two", "A3");
			Assert.AreEqual (((DataGridColumn) columns [2]).HeaderText, "three", "A4");

			// AutoGenerated columns are not added to the ColumnsCollection
			Assert.AreEqual (p.Columns.Count, 0, "A5");
			
			// Without allowing data dinding,
			columns = p.CreateColumns (source, false);
			Assert.AreEqual (columns.Count, 3, "A6");
			Assert.AreEqual (((DataGridColumn) columns [0]).HeaderText, "one", "A7");
			Assert.AreEqual (((DataGridColumn) columns [1]).HeaderText, "two", "A8");
			Assert.AreEqual (((DataGridColumn) columns [2]).HeaderText, "three", "A9");


			// Mixing with already added columns
			p = new DataGridPoker ();
			DataGridColumn a = new ButtonColumn ();
			DataGridColumn b = new ButtonColumn ();

			a.HeaderText = "A";
			b.HeaderText = "B";
			p.Columns.Add (a);
			p.Columns.Add (b);

			columns = p.CreateColumns (source, true);
			Assert.AreEqual (columns.Count, 5, "A6");
			Assert.AreEqual (((DataGridColumn) columns [0]).HeaderText, "A", "A10");
			Assert.AreEqual (((DataGridColumn) columns [1]).HeaderText, "B", "A11");
			Assert.AreEqual (((DataGridColumn) columns [2]).HeaderText, "one", "A12");
			Assert.AreEqual (((DataGridColumn) columns [3]).HeaderText, "two", "A13");
			Assert.AreEqual (((DataGridColumn) columns [4]).HeaderText, "three", "A14");

			// Assigned properties of the newly created columns
			BoundColumn one = (BoundColumn) columns [2];

			Assert.AreEqual (one.HeaderText, "one", "A15");
			Assert.AreEqual (one.DataField, "one", "A16");
			Assert.AreEqual (one.DataFormatString, String.Empty, "A17");
			Assert.AreEqual (one.SortExpression, "one", "A18");
			Assert.AreEqual (one.HeaderImageUrl, String.Empty, "A19");
			Assert.AreEqual (one.FooterText, String.Empty, "A20");
		}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:58,代码来源:DataGridTest.cs


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