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


C# DrawListViewColumnHeaderEventArgs.DrawBackground方法代码示例

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


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

示例1: OnDrawColumnHeader

 protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e)
 {
     base.OnDrawColumnHeader(e);
     if (e.ColumnIndex == 0)
     {
         var headerCheckBox = new CheckBox {Text = "", Visible = true};
         SuspendLayout();
         e.DrawBackground();
         headerCheckBox.BackColor = Color.Transparent;
         headerCheckBox.UseVisualStyleBackColor = true;
         headerCheckBox.BackgroundImage = Resources.ListViewHeaderCheckboxBackgroud;
         headerCheckBox.SetBounds(e.Bounds.X, e.Bounds.Y,
                                  headerCheckBox.GetPreferredSize(new Size(e.Bounds.Width, e.Bounds.Height)).
                                      Width,
                                  headerCheckBox.GetPreferredSize(new Size(e.Bounds.Width, e.Bounds.Height)).
                                      Height);
         headerCheckBox.Size =
             new Size(headerCheckBox.GetPreferredSize(new Size(e.Bounds.Width - 1, e.Bounds.Height)).Width + 1,
                      e.Bounds.Height);
         headerCheckBox.Location = new Point(4, 0);
         Controls.Add(headerCheckBox);
         headerCheckBox.Show();
         headerCheckBox.BringToFront();
         e.DrawText(TextFormatFlags.VerticalCenter | TextFormatFlags.Left);
         headerCheckBox.CheckedChanged += OnHeaderCheckboxCheckedChanged;
         ResumeLayout(true);
     }
     else
     {
         e.DrawDefault = true;
     }
 }
开发者ID:luowei98,项目名称:RobertLw,代码行数:32,代码来源:ListViewHeaderCheckboxEx.cs

示例2: OnDrawColumnHeader

        protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e)
        {
            base.OnDrawColumnHeader(e);
            e.DrawBackground();
            e.DrawText();

            //e.BackColor = System.Drawing.Color.AliceBlue;
        }
开发者ID:kener1985,项目名称:MyGitHubProj,代码行数:8,代码来源:MyListView.cs

示例3: HiddenWindowsListView_DrawColumnHeader

        private void HiddenWindowsListView_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
        {
            switch (e.ColumnIndex)
            {
                case 1:
                    e.DrawBackground();
                    e.Graphics.AddImage(e.Bounds, ActionResource.lockwindow_small);
                    break;

                case 2:
                    e.DrawBackground();
                    e.Graphics.AddImage(e.Bounds, ActionResource.tack_small);
                    break;

                default:
                    e.DrawDefault = true;
                    break;
            }
        }
开发者ID:priestofpsi,项目名称:Hide-My-Window,代码行数:19,代码来源:HiddenWindowsListView.cs

示例4: DataListView_DrawColumnHeader

 /// <summary>
 /// Draws Column Header text
 /// </summary>
 private void DataListView_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
 {
     //Draw the standard header background.
     e.DrawBackground();
     //Draw header text
     using (StringFormat sf = new StringFormat())
         e.Graphics.DrawString(e.Header.Text, DataListView.Font,
             Brushes.Black, e.Bounds, sf);
 }
开发者ID:ServerGame,项目名称:MemoryScanner,代码行数:12,代码来源:MemoryViewer.cs

示例5: OnDrawColumnHeader

        /// <summary>
        /// Performs custom actions when owner draws columns header</summary>
        /// <param name="e">Draw ListView column header event args</param>
        protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e)
        {
            base.OnDrawColumnHeader(e);
            using (StringFormat sf = new StringFormat())
            {
                // Store the column text alignment, letting it default
                // to Left if it has not been set to Center or Right.
                switch (e.Header.TextAlign)
                {
                    case HorizontalAlignment.Center:
                        sf.Alignment = StringAlignment.Center;
                        break;
                    case HorizontalAlignment.Right:
                        sf.Alignment = StringAlignment.Far;
                        break;
                }


                // Draw the standard header background.
                e.DrawBackground();
                                
                // Draw the header text.
                var bound = e.Bounds;
                bound.Y += 3;
                bound.X += 8;
                if (e.ColumnIndex == 0)
                    bound.X += CheckBoxWidth;

                var brush = Enabled ? m_columnHeaderTextBrush : m_columnHeaderTextBrushDisabled;
                e.Graphics.DrawString(e.Header.Text, HeaderFont, brush, bound, sf);


                if (e.ColumnIndex == m_sortColumn) // Draw sort arrow
                {
                    float w = e.Graphics.MeasureString(e.Header.Text, HeaderFont).Width;
                    if (m_sortColumn == 0)
                        w += CheckBoxWidth + 2; 
                    if (e.Bounds.Width > w + s_sortAscendingImage.Width + 8) // get enough room left for the arrow icon
                    {
                        Point pt = new Point(e.Bounds.Location.X + e.Bounds.Width - s_sortAscendingImage.Width - 4,
                        e.Bounds.Top + (e.Bounds.Height - s_sortAscendingImage.Height) / 2);
                        if (m_sortDirection == ListSortDirection.Ascending)
                            e.Graphics.DrawImage(s_sortAscendingImage, pt);
                        else
                            e.Graphics.DrawImage(s_sortDescendingImage, pt);
                    }
                }

                if (CheckBoxes && e.ColumnIndex ==0)
                {
                    // draw check mark
                    Point pt = new Point(e.Bounds.Location.X, e.Bounds.Top + 3);
                    e.Graphics.DrawString(m_tickSymbol, m_tickFont, Enabled ? m_columnHeaderCheckMarkBrush : m_columnHeaderCheckMarkBrushDisabled, pt);
                   
                    // draw a vertical line to make check mark appear in its own column                 
                    e.Graphics.DrawLine(m_columnHeaderSeparatorPen, CheckBoxWidth, e.Bounds.Top,
                        CheckBoxWidth, e.Bounds.Bottom - 2);
                   
                }
            }
        }
开发者ID:sbambach,项目名称:ATF,代码行数:64,代码来源:DataBoundListView.cs

示例6: DrawColumnHeader

 private void DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
 {
     e.DrawDefault = true;
     e.DrawBackground();
     e.DrawText();
 }
开发者ID:khoavnguyen,项目名称:cs333,代码行数:6,代码来源:DisplayForm.cs

示例7: listView1_DrawColumnHeader

        private void listView1_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
        {
            e.DrawBackground();
              var brush = regularStateBrush;
              if (e.Header.Index == 1)
            brush = currentStateBrush;
              else if (e.Header.Index == 2)
            brush = previousStateBrush;

              Rectangle r = e.Bounds;
              r.X += 5;
              r.Y += 4;
              DrawString(e.Graphics, e.Header.Text, e.Header.ListView.Font, brush, r);
        }
开发者ID:Chenguang-Zhu,项目名称:ICE-C5,代码行数:14,代码来源:Main.cs

示例8: lvPlugins_DrawColumnHeader

 private void lvPlugins_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
 {
     if (e.ColumnIndex == 0)
     {
         e.DrawBackground();
         bool value = false;
         try
         {
             value = Convert.ToBoolean(e.Header.Tag);
         }
         catch (Exception)
         {
         }
         CheckBoxRenderer.DrawCheckBox(e.Graphics,
             new Point(e.Bounds.Left + 4, e.Bounds.Top + 4),
             value ? System.Windows.Forms.VisualStyles.CheckBoxState.CheckedNormal :
             System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal);
     }
     else
     {
         e.DrawDefault = true;
     }
 }
开发者ID:gfritz,项目名称:XrmToolBox,代码行数:23,代码来源:PluginsChecker.cs

示例9: OnDrawColumnHeader

        private static void OnDrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
        {
            using ( StringFormat sf = new StringFormat())
            {
                // Workout the text alignment
                switch( e.Header.TextAlign)
                {
                    case HorizontalAlignment.Center:
                        sf.Alignment = StringAlignment.Center;
                        break;
                    case HorizontalAlignment.Right:
                        sf.Alignment = StringAlignment.Far;
                        break;
                }

                // Draw the standard background
                e.DrawBackground();

                // Draw the header text
                using ( Font headerFont = new Font(View.Font.FontFamily, View.Font.Size))
                {
                    e.Graphics.DrawString(e.Header.Text, headerFont, Brushes.Blue, e.Bounds, sf);
                }
            }
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:25,代码来源:BaseView.cs

示例10: DrawColumnHeader

        /// <summary>
        /// Takes care of drawing a column header using an image.
        /// </summary>
        /// <param name="e">The DrawListViewColumnHeader event arguments.</param>
        /// <param name="colH">The ColumnHeader to be drawn.</param>
        /// <param name="img">The Image where to draw the column.</param>
        private static void DrawColumnHeader(DrawListViewColumnHeaderEventArgs e, ColumnHeader colH, Image img)
        {
            int width = TextRenderer.MeasureText(" ", e.Font).Width;
            string text = colH.Text;
            HorizontalAlignment textAlign = colH.TextAlign;
            TextFormatFlags flags = (textAlign == HorizontalAlignment.Left) ? TextFormatFlags.GlyphOverhangPadding : ((textAlign == HorizontalAlignment.Center) ? TextFormatFlags.HorizontalCenter : TextFormatFlags.Right);
            flags |= TextFormatFlags.WordEllipsis | TextFormatFlags.VerticalCenter;

            if (img != null)
            {
                int halfWidth = width / 2;

                Rectangle imgBounds = new Rectangle(e.Bounds.Location.X + halfWidth, e.Bounds.Location.Y + 1, e.Bounds.Size.Height, e.Bounds.Size.Height - 3);
                Rectangle txtBounds = new Rectangle(imgBounds.Location.X + imgBounds.Size.Width + halfWidth, e.Bounds.Location.Y, e.Bounds.Size.Width - (imgBounds.Size.Width + 2 * halfWidth), e.Bounds.Size.Height);

                e.DrawBackground();
                e.Graphics.DrawImage(img, imgBounds);
                TextRenderer.DrawText(e.Graphics, text, e.Font, txtBounds, e.ForeColor, flags);
            }
            else
            {
                e.DrawBackground();
                TextRenderer.DrawText(e.Graphics, text, e.Font, e.Bounds, e.ForeColor, flags);
            }
        }
开发者ID:WebMAPTestUser,项目名称:SKS,代码行数:31,代码来源:ListViewHelper.cs

示例11: DhListView_DrawColumnHeader

		void DhListView_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
		{
			var paleBlue = Color.FromArgb(187, 235, 254);
			var veryPaleBlue = Color.FromArgb(227, 247, 255);
			var lightBlue = Color.LightBlue;
			var drawRect = e.Bounds;
			// For some reason Bounds.Height is much too big. Bigger than our whole control!
			drawRect.Height = Height - 4;
			int imageIndex;
			//e.Header.Index is it's index in the original, un-dragged list of columns.
			//m_columnIconIndexes is indexed by the current display position of columns that require the icon to be displayed.
			var currentDisplayPositionOfColumn = OrderForColumnsDisplay[e.Header.Index];
			if (!m_columnIconIndexes.TryGetValue(currentDisplayPositionOfColumn, out imageIndex))
				imageIndex = -1;
			if (imageIndex >= 0)
				drawRect.Width -= m_imgList.ImageSize.Width;

			var topHeight = drawRect.Height / 2 - 1;
			var drawText = e.Header.Text;
			var realSize = e.Graphics.MeasureString(drawText, e.Font);
			if ((e.State & ListViewItemStates.Selected) != 0)
			{
				using (var brush = new SolidBrush(paleBlue))
				{
					e.Graphics.FillRectangle(brush, new Rectangle(e.Bounds.Left, e.Bounds.Top, e.Bounds.Width, topHeight));
				}
				using (var brush = new SolidBrush(lightBlue))
				{
					e.Graphics.FillRectangle(brush, new Rectangle(e.Bounds.Left, e.Bounds.Top + topHeight, e.Bounds.Width, e.Bounds.Height - topHeight));
				}
			}
			else if (e.Bounds.Contains(PointToClient(Cursor.Position))) // seems to be no state that indicates mouse is in it...Hot should but doesn't.
			{
				m_hotRectangle = e.Bounds;
				if (m_timer == null)
				{
					m_timer = new Timer();
					m_timer.Interval = 50;
					m_timer.Tick += m_timer_Tick;
					m_timer.Start();
				}
				m_cTicks = 0;
				if (realSize.Width > drawRect.Width)
				{
					m_tooltipText = drawText;
				}
				else
				{
					m_tooltipText = null;
				}
				using (var brush = new SolidBrush(veryPaleBlue))
				{
					e.Graphics.FillRectangle(brush, new Rectangle(e.Bounds.Left, e.Bounds.Top, e.Bounds.Width, topHeight));
				}
				using (var brush = new SolidBrush(paleBlue))
				{
					e.Graphics.FillRectangle(brush, new Rectangle(e.Bounds.Left, e.Bounds.Top + topHeight, e.Bounds.Width, e.Bounds.Height - topHeight));
				}
			}
			else
			{
				e.DrawBackground(); // standard background
			}
			// Draw the header text.
			if (realSize.Width > drawRect.Width)
			{
				// Guess how much we can fit.
				int len = (int)(drawText.Length * drawRect.Width / realSize.Width) + 1;

				// Subtract more until it fits.
				do
				{
					len = len - 1;
					Debug.Assert(len >= 0, "length should not be negative");
					drawText = drawText.Substring(0, len) + "\x2026"; // ellipsis
					realSize = e.Graphics.MeasureString(drawText, e.Font);
				} while (len > 0 && realSize.Width > drawRect.Width);

				// Add any more that fits.
				while (len < e.Header.Text.Length - 1)
				{
					len = len + 1;
					var possibleText = e.Header.Text.Substring(0, len) + "\x2026"; // ellipsis
					realSize = e.Graphics.MeasureString(possibleText, e.Font);
					if (realSize.Width > drawRect.Width)
						break; // we can't add this one more character.
					drawText = possibleText; // we can fit this much at least.
				}
			}
			using (StringFormat sf = new StringFormat())
			{
				sf.Trimming = StringTrimming.Character;
				sf.FormatFlags = StringFormatFlags.NoWrap;
				sf.LineAlignment = StringAlignment.Far; // bottom

				//if (drawRect.Height > realSize.Height - 2)
				//{
				//    drawRect = new Rectangle(drawRect.X, drawRect.Top + drawRect.Height - (int)realSize.Height - 2, drawRect.Width, (int)realSize.Height + 2);
				//}
				e.Graphics.DrawString(drawText, e.Font,
//.........这里部分代码省略.........
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:101,代码来源:DhListView.cs

示例12: ListViewOnDrawColumnHeader

        private void ListViewOnDrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
        {
            e.DrawBackground();
            e.Graphics.FillRectangle(new SolidBrush(CurrentBaseSkin.BackColor), e.Bounds);
            e.Graphics.DrawLine(new Pen(CurrentBaseSkin.ForeColor, 1), e.Bounds.Left, e.Bounds.Bottom - 2,
                e.Bounds.Right,
                e.Bounds.Bottom - 2);
            e.Graphics.DrawLine(new Pen(CurrentBaseSkin.ForeColor, 1), e.Bounds.Left - 1, e.Bounds.Bottom - 2,
                e.Bounds.Left - 1,
                0);

            using (var sf = new StringFormat
            {
                Alignment = StringAlignment.Near,
                LineAlignment = StringAlignment.Center
            })
                e.Graphics.DrawString(e.Header.Text, CurrentBaseSkin.Font, new SolidBrush(CurrentBaseSkin.ForeColor),
                    e.Bounds, sf);
        }
开发者ID:Jonno12345,项目名称:TileIconifier,代码行数:19,代码来源:SkinnableForm.cs

示例13: lvLibrary_DrawColumnHeader

        void lvLibrary_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
        {
            //https://msdn.microsoft.com/en-us/library/system.windows.forms.listview.ownerdraw%28v=vs.110%29.aspx
            using (StringFormat sf = new StringFormat()) {
                // Store the column text alignment, letting it default
                // to Left if it has not been set to Center or Right.
                switch (e.Header.TextAlign) {
                    case HorizontalAlignment.Center:
                        sf.Alignment = StringAlignment.Center;
                        break;
                    case HorizontalAlignment.Right:
                        sf.Alignment = StringAlignment.Far;
                        break;
                }

                // Draw the standard header background.
                e.DrawBackground();

                // Draw the header text.
                using (Font headerFont =
                            new Font("Helvetica", 10, FontStyle.Bold)) {
                    e.Graphics.DrawString(e.Header.Text, headerFont,
                        Brushes.Black, e.Bounds, sf);
                }
            }
        }
开发者ID:Lords08,项目名称:alanarduinotools,代码行数:26,代码来源:UcLibraryList.cs

示例14: currentList_DrawColumnHeader

		/// <summary>
		/// Owner draw requires drawing the column header as well as the list items.  See LT-7007.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		void currentList_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
		{
			e.DrawBackground();
			e.DrawText();
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:10,代码来源:ConfigureInterlinDialog.cs

示例15: listView_DrawColumnHeader

 private void listView_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
 {
     e.DrawBackground();
     e.DrawText();
 }
开发者ID:oojjrs,项目名称:Nuri4,代码行数:5,代码来源:TextForm.cs


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