System.Windows.Forms.DrawListViewSubItemEventArgs.DrawText C# (CSharp) Method

DrawText() public method

public DrawText ( TextFormatFlags flags ) : void
flags TextFormatFlags
return void
        public void DrawText (TextFormatFlags flags)
        {
		// Text adjustments
		Rectangle text_bounds = new Rectangle (bounds.X + 8, bounds.Y, bounds.Width - 13, bounds.Height);
		TextRenderer.DrawText (graphics, subItem.Text, subItem.Font, text_bounds, subItem.ForeColor, flags);
        }

Same methods

DrawListViewSubItemEventArgs::DrawText ( ) : void

Usage Example

Example #1
0
        private void listView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            if (e.ColumnIndex == 1)
            {
                using (var ms = new MemoryStream())
                {
                    using (var sw = new StreamWriter(ms))
                    {
                        sw.Write(e.SubItem.Text);
                        sw.Flush();
                        ms.Seek(0, SeekOrigin.Begin);

                        var rtb = new RichTextBox();
                        {
                            rtb.BorderStyle = BorderStyle.None;
                            rtb.LoadFile(ms, RichTextBoxStreamType.RichText);
                            rtb.Location = e.SubItem.Bounds.Location;
                            rtb.Size = e.SubItem.Bounds.Size;
                            rtb.Parent = sender as Control;

                            var bmp = new Bitmap(128, 32);
                            rtb.DrawToBitmap(bmp, rtb.DisplayRectangle);
                            //bmp.Save("test.bmp");

                            e.Graphics.DrawImageUnscaledAndClipped(bmp, e.SubItem.Bounds);
                            //e.DrawBackground();
                            //e.Graphics.DrawString(rtb.Text, SystemFonts.DefaultFont, SystemBrushes.ControlText, e.SubItem.Bounds);
                        }
                    }
                }
            }
            else
            {
                e.DrawBackground();
                e.DrawText();
            }
        }
All Usage Examples Of System.Windows.Forms.DrawListViewSubItemEventArgs::DrawText