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


C# ListView.GetReorderedColumn方法代码示例

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


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

示例1: DrawListViewHeader

		public override void DrawListViewHeader (Graphics dc, Rectangle clip, ListView control)
		{	
			bool details = (control.View == View.Details);
				
			// border is drawn directly in the Paint method
			if (details && control.HeaderStyle != ColumnHeaderStyle.None) {				
				dc.FillRectangle (SystemBrushes.Control,
						  0, 0, control.TotalWidth, control.Font.Height + 5);
				if (control.Columns.Count > 0) {
					foreach (ColumnHeader col in control.Columns) {
						Rectangle rect = col.Rect;
						rect.X -= control.h_marker;

#if NET_2_0
						bool owner_draw = false;
						if (control.OwnerDraw)
							owner_draw = DrawListViewColumnHeaderOwnerDraw (dc, control, col, rect);
						if (owner_draw)
							continue;
#endif

						ListViewDrawColumnHeaderBackground (control, col, dc, rect, clip);
						rect.X += 5;
						rect.Width -= 10;
						if (rect.Width <= 0)
							continue;

#if NET_2_0
						int image_index;
						if (control.SmallImageList == null)
							image_index = -1;
						else 
							image_index = col.ImageKey == String.Empty ? col.ImageIndex : control.SmallImageList.Images.IndexOfKey (col.ImageKey);

						if (image_index > -1 && image_index < control.SmallImageList.Images.Count) {
							int image_width = control.SmallImageList.ImageSize.Width + 5;
							int text_width = (int)dc.MeasureString (col.Text, control.Font).Width;
							int x_origin = rect.X;
							int y_origin = rect.Y + ((rect.Height - control.SmallImageList.ImageSize.Height) / 2);

							switch (col.TextAlign) {
								case HorizontalAlignment.Left:
									break;
								case HorizontalAlignment.Right:
									x_origin = rect.Right - (text_width + image_width);
									break;
								case HorizontalAlignment.Center:
									x_origin = (rect.Width - (text_width + image_width)) / 2 + rect.X;
									break;
							}

							if (x_origin < rect.X)
								x_origin = rect.X;

							control.SmallImageList.Draw (dc, new Point (x_origin, y_origin), image_index);
							rect.X += image_width;
							rect.Width -= image_width;
						}
#endif

						dc.DrawString (col.Text, control.Font, SystemBrushes.ControlText, rect, col.Format);
					}
					int right = control.GetReorderedColumn (control.Columns.Count - 1).Rect.Right - control.h_marker;
					if (right < control.Right) {
						Rectangle rect = control.Columns [0].Rect;
						rect.X = right;
						rect.Width = control.Right - right;
						ListViewDrawUnusedHeaderBackground (control, dc, rect, clip);
					}
				}
			}
		}
开发者ID:hindlemail,项目名称:mono,代码行数:72,代码来源:ThemeWin32Classic.cs


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