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


C# ListView.CreateGraphics方法代码示例

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


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

示例1: ListViewGetHeaderHeight

		public override int ListViewGetHeaderHeight (ListView listView, Font font)
		{
			if (!RenderClientAreas)
				return base.ListViewGetHeaderHeight (listView, font);
			VisualStyleElement element = VisualStyleElement.Header.Item.Normal;
			if (!VisualStyleRenderer.IsElementDefined (element))
				return base.ListViewGetHeaderHeight (listView, font);
			Control control = null;
			Graphics g;
			if (listView == null) {
				control = new Control ();
				g = control.CreateGraphics ();
			} else
				g = listView.CreateGraphics ();
			int result = new VisualStyleRenderer (element).GetPartSize (g, ThemeSizeType.True).Height;
			g.Dispose ();
			if (listView == null)
				control.Dispose ();
			return result;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:20,代码来源:ThemeVisualStyles.cs

示例2: drawCheckBox

        /// <summary>
        /// 在ListView的子项里绘制一个checkbox
        /// </summary>
        /// <param name="listView"></param>
        /// <param name="subItem"></param>
        /// <param name="isChecked"></param>
        private void drawCheckBox(ListView listView, ListViewItem.ListViewSubItem subItem, bool isChecked)
        {
            Graphics graph = listView.CreateGraphics();

            Image icon = getCheckBoxImage(isChecked);

            Brush brush = new SolidBrush(subItem.BackColor);
            graph.FillRectangle(brush, subItem.Bounds.X + 1, subItem.Bounds.Y + 1, subItem.Bounds.Width - 2, subItem.Bounds.Height - 2);
            graph.DrawImage(icon, new Point(subItem.Bounds.X + 5, subItem.Bounds.Y));

            graph.Dispose();
        }
开发者ID:easysoft,项目名称:zentao_extension,代码行数:18,代码来源:IssuesForm.cs

示例3: GetMaximumColumnWidths

        /// <summary>
        /// 
        /// </summary>
        /// <param name="lv"></param>
        /// <returns></returns>
        public static Int32[] GetMaximumColumnWidths(ListView lv)
        {
            Int32 index = 0;
             Int32[] widthArray = new Int32[lv.Columns.Count];

             foreach (ColumnHeader col in lv.Columns)
             {
            widthArray[index] = col.Width;
            index++;
             }

             System.Drawing.Graphics g = lv.CreateGraphics();
             Int32 offset = Convert.ToInt32(Math.Ceiling(g.MeasureString(" ", lv.Font).Width));
             Int32 width = 0;

             foreach (ListViewItem item in lv.Items)
             {
            index = 0;

            foreach (ListViewItem.ListViewSubItem subItem in item.SubItems)
            {
               width = Convert.ToInt32(Math.Ceiling(g.MeasureString(subItem.Text, item.Font).Width)) + offset;
               if (width > widthArray[index])
               {
                  widthArray[index] = width;
               }
               index++;
            }
             }

             g.Dispose();

             return widthArray;
        }
开发者ID:jeremytammik,项目名称:RevitLookup,代码行数:39,代码来源:Utils.cs

示例4: AutoResizeColumnWidth

        private void AutoResizeColumnWidth(ListView lv)
        {
            int count = lv.Columns.Count;
            int MaxWidth = 0;
            Graphics graphics = lv.CreateGraphics();
            Font font = lv.Font;
            ListView.ListViewItemCollection items = lv.Items;

            string str;
            int width;

            lv.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);

            for (int i = 0; i < count; i++)
            {
                str = lv.Columns[i].Text;
                MaxWidth = lv.Columns[i].Width;

                foreach (ListViewItem item in items)
                {
                    if (item.SubItems.Count > i)
                    {
                        str = item.SubItems[i].Text;
                        width = (int)graphics.MeasureString(str, font).Width;
                        if (width > MaxWidth)
                        {
                            MaxWidth = width;
                        }
                    }
                }
                if (i == 0)
                {
                    lv.Columns[i].Width = lv.SmallImageList.ImageSize.Width + MaxWidth;
                }
                else if (i == 1)
                {
                    lv.Columns[i].Width = 60;
                }
                else
                {
                    lv.Columns[i].Width = MaxWidth;
                }
            }
        }
开发者ID:harryho,项目名称:demo-fx-trading-platform-prototype,代码行数:44,代码来源:FxAnalyzerControl.cs


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