Exemplo n.º 1
0
		private void PrepareControlHierarchyForItem (DataGridColumn [] cols,
							     DataGridItem item,
							     int index,
							     Style deployStyle)
		{
			switch (item.ItemType) {
			case ListItemType.Header:
				if (!ShowHeader) {
					item.Visible = false;
					break;
				}

				if (headerStyle != null)
					item.MergeStyle (headerStyle);

				goto case ListItemType.Separator;
			case ListItemType.Footer:
				if (!ShowFooter) {
					item.Visible = false;
					break;
				}

				if (footerStyle != null)
					item.MergeStyle (footerStyle);

				goto case ListItemType.Separator;
			case ListItemType.Item  :
				item.MergeStyle (itemStyle);
				goto case ListItemType.Separator;
			case ListItemType.AlternatingItem:
				item.MergeStyle (deployStyle);
				goto case ListItemType.Separator;
			case ListItemType.SelectedItem:
				Style selStyle = new TableItemStyle ();
				if ((item.ItemIndex % 2) == 0) {
					selStyle.CopyFrom (itemStyle);
				} else {
					selStyle.CopyFrom (deployStyle);
				}

				selStyle.CopyFrom (selectedItemStyle);
				item.MergeStyle (selStyle);
				goto case ListItemType.Separator;
			case ListItemType.EditItem:
				Style edStyle = new TableItemStyle ();
				if ((item.ItemIndex % 2) == 0) {
					edStyle.CopyFrom (itemStyle);
				} else {
					edStyle.CopyFrom (deployStyle);
				}

				edStyle.CopyFrom (editItemStyle);
				item.MergeStyle (edStyle);
				goto case ListItemType.Separator;
			case ListItemType.Pager:
				if (pagerStyle == null)
					break;

				if (!pagerStyle.Visible)
					item.Visible = false;

				if (index == 0) {
					if (!pagerStyle.IsPagerOnTop) {
						item.Visible = false;
						break;
					}
				} else if (!pagerStyle.IsPagerOnBottom) {
					item.Visible = false;
					break;
				}

				item.MergeStyle (pagerStyle);
				goto case ListItemType.Separator;
			case ListItemType.Separator:
				TableCellCollection cells = item.Cells;
				int cellCount = cells.Count;
				if (cellCount > cols.Length)
					cellCount = cols.Length;

				if (cellCount > 0 && item.ItemType != ListItemType.Pager) {
					for (int i = 0; i < cellCount; i++) {
						Style colStyle = null;
						if (cols [i].Visible) {
							switch (item.ItemType) {
							case ListItemType.Header:
								colStyle = cols [i].HeaderStyleInternal;
								break;
							case ListItemType.Footer:
								colStyle = cols [i].FooterStyleInternal;
								break;
							default:
								colStyle = cols [i].ItemStyleInternal;
								break;
							}
							cells[i].MergeStyle (colStyle);
						} else {
							cells [i].Visible = false;
						}
					}
				}
				break;
			default:
				goto case ListItemType.Separator;
			}
		}
Exemplo n.º 2
0
		void ApplyItemStyle (DataGridItem item)
		{
			if (item.ItemIndex % 2 != 0)
				item.MergeStyle (alt_item_style);

			item.MergeStyle (item_style);
			ApplyColumnStyle (item.Cells, ListItemType.Item);
		}