當前位置: 首頁>>代碼示例>>C#>>正文


C# DrawListViewSubItemEventArgs.DrawText方法代碼示例

本文整理匯總了C#中System.Windows.Forms.DrawListViewSubItemEventArgs.DrawText方法的典型用法代碼示例。如果您正苦於以下問題:C# DrawListViewSubItemEventArgs.DrawText方法的具體用法?C# DrawListViewSubItemEventArgs.DrawText怎麽用?C# DrawListViewSubItemEventArgs.DrawText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Forms.DrawListViewSubItemEventArgs的用法示例。


在下文中一共展示了DrawListViewSubItemEventArgs.DrawText方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: listView_DrawSubItem

        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();
            }
        }
開發者ID:oojjrs,項目名稱:Nuri4,代碼行數:37,代碼來源:TextForm.cs

示例2: listView_DrawSubItem

 private void listView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
 {
     e.DrawBackground();
     e.DrawText();
 }
開發者ID:strillo,項目名稱:ServiceBusExplorer,代碼行數:5,代碼來源:PartitionListenerControl.cs

示例3: listView_DrawSubItem

 /*************************************************************
  * CSVリストビューを縞模様に描畫
  *************************************************************/
 private void listView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
 {
     // 奇數行の場合は背景色を変更し、縞々に見えるようにする
     if (e.ItemIndex % 2 > 0)
     {
         e.Graphics.FillRectangle(Brushes.Azure, e.Bounds);
     }
     // テキストを忘れずに描畫する
     e.DrawText();
 }
開發者ID:takashi0419,項目名稱:CostAccounting,代碼行數:13,代碼來源:Form_Prepare_ProductReg.cs

示例4: listViewFilterItem_DrawSubItem

 private void listViewFilterItem_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
 {
     e.DrawText();
 }
開發者ID:huizh,項目名稱:xenadmin,代碼行數:4,代碼來源:WlbReportCustomFilter.cs

示例5: listView_DrawSubItem

 private void listView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
 {
     Brush brush;
     Color backColor;
     Color foreColor;
     if (e.Item.Selected)
     {
         if (listView.Focused)
         {
             brush = SystemBrushes.Highlight;
             backColor = SystemColors.Highlight;
             foreColor = SystemColors.HighlightText;
         }
         else
         {
             // We use the same colors here as TreeViewMS does for
             // drawing unfocused selected rows.
             brush = Brushes.LightGray;
             backColor = Color.LightGray;
             foreColor = SystemColors.WindowText;
         }
     }
     else
     {
         brush = SystemBrushes.Window;
         backColor = SystemColors.Window;
         foreColor = SystemColors.WindowText;
     }
     if (e.ColumnIndex == 0)
     {
         // Erase the entire background when drawing the first sub-item
         e.Graphics.FillRectangle(brush, e.Item.Bounds);
     }
     if (e.ColumnIndex == colHdrDisplayText.Index)
     {
         var findResult = (FindResult) e.Item.Tag;
         var textRendererHelper = new TextRendererHelper
                                      {
                                          ForeColor = foreColor,
                                          BackColor = backColor,
                                          Font = e.Item.Font,
                                          HighlightFont = new Font(e.Item.Font, FontStyle.Bold),
                                      };
         textRendererHelper.DrawHighlightedText(e.Graphics, e.SubItem.Bounds, findResult.FindMatch);
     }
     else
     {
         e.SubItem.ForeColor = foreColor;
         e.DrawText();
     }
     if (e.ColumnIndex == 0)
     {
         e.DrawFocusRectangle(e.Bounds);
     }
 }
開發者ID:lgatto,項目名稱:proteowizard,代碼行數:55,代碼來源:FindResultsForm.cs

示例6: nodeListView_DrawSubItem

        private void nodeListView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            if (e.ColumnIndex > 0)
            {
                Rectangle bounds = e.SubItem.Bounds;

                if (e.Item.Selected)
                {
                    e.Graphics.FillRectangle(HL_BRUSH, bounds);
                    e.SubItem.ForeColor = SystemColors.HighlightText;
                }
                else
                {
                    e.Graphics.FillRectangle(new SolidBrush(e.Item.BackColor), bounds);
                    e.SubItem.ForeColor = e.Item.ForeColor;
                }

                e.DrawText(TextFormatFlags.VerticalCenter);
                e.Graphics.DrawLine(LINE_PEN, bounds.Left, bounds.Top, bounds.Left, bounds.Bottom);
            }
            else
            {
                e.DrawDefault = true;
            }
        }
開發者ID:sschocke,項目名稱:BrainSimulator,代碼行數:25,代碼來源:NodeSelectionForm.cs

示例7: DrawSubItem

        private void DrawSubItem(DrawListViewSubItemEventArgs e, decimal Width, bool Focused)
        {
            Rectangle rect, origrect = e.Bounds;
            if (Focused)
                e.Graphics.FillRectangle(SystemBrushes.Highlight, origrect); // Draw the background and focus rectangle for a selected item.
            else
                e.Graphics.FillRectangle(new SolidBrush(e.Item.BackColor), origrect); // Draw the background for an unselected item.

            origrect.X += 1;
            origrect.Y += 1;
            origrect.Height -= 3;
            origrect.Width -= 3;
            rect = origrect;
            e.Graphics.FillRectangle(new SolidBrush(e.Item.BackColor), rect);
            rect.Width = (int)((double)Width / 100.0 * origrect.Width);

            if (rect.Width > 0 && rect.Height > 0)
            {
                Brush br;
                if (Program.Settings.NoGradientTorrentList)
                    br = new SolidBrush(Color.LimeGreen);
                else
                    br = new LinearGradientBrush(rect, Color.ForestGreen, Color.LightGreen, LinearGradientMode.Horizontal);

                e.Graphics.FillRectangle(br, rect);
            }
            e.Graphics.DrawRectangle(LightLightGray, origrect);
            e.DrawText(TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter);
        }
開發者ID:miracle091,項目名稱:transmission-remote-dotnet,代碼行數:29,代碼來源:MainWindow.cs

示例8: DrawSubItem

 private void DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
 {
     TextFormatFlags flag = e.ColumnIndex > 0 ? TextFormatFlags.HorizontalCenter : TextFormatFlags.Left;
     e.DrawBackground();
     e.DrawText(flag);
 }
開發者ID:khoavnguyen,項目名稱:cs333,代碼行數:6,代碼來源:DisplayForm.cs

示例9: listView_DrawSubItem

        void listView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            // 選択されている場合
            if (e.Item.Selected) {
                e.Graphics.FillRectangle(Brushes.LightGray, e.Bounds);
            } else {
                // 自デバイス宛のパケットだけ色を変える
                if (Adapter != null) {
                    if(e.Item.Tag.ToString().ToUpper() == Adapter.Mac.ToUpper()){
                        e.Graphics.FillRectangle(Brushes.LightSteelBlue, e.Bounds);
                    }
                }
            }

            // テキストを描畫
            e.DrawText();
        }
開發者ID:furuya02,項目名稱:HideAndSeek,代碼行數:17,代碼來源:CaptureView.cs

示例10: lvServerBrowser_DrawSubItem

        private void lvServerBrowser_DrawSubItem(Object sender, DrawListViewSubItemEventArgs e)
        {
            if (e.ColumnIndex == 0)
            {
                Image imgLock = Properties.Resources.theLock;
                Image imgUnlock = Properties.Resources.theUnlock;

                if (lvServerBrowser.Items[e.ItemIndex].SubItems[e.ColumnIndex].Text.Equals("true"))
                {
                    e.Graphics.DrawImage(imgLock, lvServerBrowser.Items[e.ItemIndex].SubItems[e.ColumnIndex].Bounds.Location);
                }
                else
                {
                    e.Graphics.DrawImage(imgUnlock, lvServerBrowser.Items[e.ItemIndex].SubItems[e.ColumnIndex].Bounds.Location);
                }
                e.DrawFocusRectangle(lvServerBrowser.Items[e.ItemIndex].SubItems[e.ColumnIndex].Bounds);
            }
            else
            {
                e.DrawText();
            }
        }
開發者ID:LaocheXe,項目名稱:1stCavDiv-Launcher,代碼行數:22,代碼來源:ServerBrowser.cs

示例11: OnListViewDrawSubItem

        private void OnListViewDrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            //Controller.WriteLine("e.SubItem.Name: {0}", e.SubItem.Text);

            if (!e.SubItem.Text.Contains("23"))
            {
                e.DrawDefault = true;
                return;
            }

            //e.DrawBackground();
            if ((e.ItemState & ListViewItemStates.Selected) == ListViewItemStates.Selected)
            {
                //
            }

            Rectangle b = new Rectangle(e.Bounds.Left + e.Bounds.Width / 4, e.Bounds.Top, e.Bounds.Width / 2, e.Bounds.Height);
            e.Graphics.FillRectangle(SystemBrushes.Highlight, b);

            e.DrawText(TextFormatFlags.Default);
        }
開發者ID:apakian,項目名稱:buggazer,代碼行數:21,代碼來源:DBWinListView.cs

示例12: lstShow_DrawSubItem

        private void lstShow_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            if (e.ColumnIndex > 0)
            {
                e.DrawBackground();

                string searchTerm = "";
                int index = e.SubItem.Text.IndexOf(searchTerm);

                if (index >= 0)
                {
                    string sBefore = e.SubItem.Text.Substring(0, index);

                    Size bounds = new Size(e.Bounds.Width, e.Bounds.Height);
                    Size s1 = TextRenderer.MeasureText(e.Graphics, sBefore, this.Font, bounds);
                    Size s2 = TextRenderer.MeasureText(e.Graphics, searchTerm, this.Font, bounds);

                    Rectangle rect = new Rectangle(e.Bounds.X + s1.Width, e.Bounds.Y, s2.Width, e.Bounds.Height);

                    e.Graphics.SetClip(e.Bounds);
                    e.Graphics.FillRectangle(new SolidBrush(Color.Yellow), rect);
                    e.Graphics.ResetClip();
                }

                e.DrawText();
            }
        }
開發者ID:RisenZhang,項目名稱:SignalAnalize,代碼行數:27,代碼來源:LogSearch.cs

示例13: lvWindows_DrawSubItem

        private void lvWindows_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            GameWindow window = Windows[e.ItemIndex];
            if (lastForegroundWindow == window.HWnd)
            {
                // Draw the background and focus rectangle for a selected item.
                e.Graphics.FillRectangle(Brushes.Maroon, e.Bounds);
            }
            else if (ActiveWindow == window)
            {
                // Draw the background and focus rectangle for a selected item.
                e.Graphics.FillRectangle(
                    new SolidBrush(System.Drawing.SystemColors.Highlight),
                    e.Bounds
                );
            }

            if (e.ColumnIndex == 0)
            {
                if (e.Item.Checked)
                {
                    ControlPaint.DrawCheckBox(e.Graphics, e.Bounds.X + 1, e.Bounds.Top + 1, 14, 14, ButtonState.Normal | ButtonState.Checked);
                }
                else
                {
                    ControlPaint.DrawCheckBox(e.Graphics, e.Bounds.X + 1, e.Bounds.Top + 1, 14, 14, ButtonState.Normal);
                }

                e.Graphics.DrawString(
                    e.Item.Text,
                    lvWindows.Font,
                    Brushes.Black,
                    new PointF(e.Bounds.X + 16, e.Bounds.Top + 1)
                );
            }
            else
            {
                e.DrawText(TextFormatFlags.VerticalCenter | TextFormatFlags.Left);
            }
        }
開發者ID:quadrowin,項目名稱:afkgamer,代碼行數:40,代碼來源:MainForm.cs

示例14: lvLibrary_DrawSubItem

        void lvLibrary_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            TextFormatFlags flags = TextFormatFlags.Left;

            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;
                        flags = TextFormatFlags.HorizontalCenter;
                        break;
                    case HorizontalAlignment.Right:
                        sf.Alignment = StringAlignment.Far;
                        flags = TextFormatFlags.Right;
                        break;
                }

                // Draw the text and background for a subitem with a
                // negative value.
                double subItemValue;
                if (e.ColumnIndex > 0 && Double.TryParse(
                    e.SubItem.Text, NumberStyles.Currency,
                    NumberFormatInfo.CurrentInfo, out subItemValue) &&
                    subItemValue < 0) {
                    // Unless the item is selected, draw the standard
                    // background to make it stand out from the gradient.
                    if ((e.ItemState & ListViewItemStates.Selected) == 0) {
                        e.DrawBackground();
                    }

                    // Draw the subitem text in red to highlight it.
                    e.Graphics.DrawString(e.SubItem.Text,
                        lvLibrary.Font, Brushes.Red, e.Bounds, sf);

                    return;
                }

                // Draw normal text for a subitem with a nonnegative
                // or nonnumerical value.
                e.DrawText(flags);
            }
        }
開發者ID:Lords08,項目名稱:alanarduinotools,代碼行數:43,代碼來源:UcLibraryList.cs

示例15: OnDrawSubItem

        private static void OnDrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            if (e.Header.Index > 0)
            {
                TextFormatFlags tff = TextFormatFlags.Left;
                // Workout the text alignment
                switch (e.Header.TextAlign)
                {
                    case HorizontalAlignment.Center:
                        tff = TextFormatFlags.HorizontalCenter;
                        break;
                    case HorizontalAlignment.Right:
                        tff = TextFormatFlags.Right;
                        break;
                }

                // draw the strings
                e.DrawText(tff);
            }
        }
開發者ID:killbug2004,項目名稱:WSProf,代碼行數:20,代碼來源:BaseView.cs


注:本文中的System.Windows.Forms.DrawListViewSubItemEventArgs.DrawText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。