本文整理汇总了C#中System.Windows.Forms.DrawListViewSubItemEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# DrawListViewSubItemEventArgs类的具体用法?C# DrawListViewSubItemEventArgs怎么用?C# DrawListViewSubItemEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DrawListViewSubItemEventArgs类属于System.Windows.Forms命名空间,在下文中一共展示了DrawListViewSubItemEventArgs类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: listView_DrawSubItem
private void listView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
Rectangle bounds = e.SubItem.Bounds;
if (e.ColumnIndex == 0)
{
bounds.Width = bounds.X + e.Item.SubItems[1].Bounds.X;
}
//toggle colors if the item is highlighted
if (e.Item.Selected && e.Item.ListView.Focused)
{
e.SubItem.BackColor = SystemColors.Highlight;
e.SubItem.ForeColor = e.Item.ListView.BackColor;
}
else if (e.Item.Selected && !e.Item.ListView.Focused)
{
e.SubItem.BackColor = SystemColors.Control;
e.SubItem.ForeColor = e.Item.ListView.ForeColor;
}
else
{
e.SubItem.BackColor = e.Item.ListView.BackColor;
e.SubItem.ForeColor = e.Item.ListView.ForeColor;
}
// Draw the standard header background.
e.DrawBackground();
int xOffset = 0;
if (e.ColumnIndex == 0)
{
Point glyphPoint = new Point(4, e.Item.Position.Y + 2);
MyTask task = e.Item.Tag as MyTask;
if (string.IsNullOrEmpty(task.TaskGroupName))
{
CheckBoxState state = e.Item.Checked ? CheckBoxState.CheckedNormal : CheckBoxState.UncheckedNormal;
CheckBoxRenderer.DrawCheckBox(e.Graphics, glyphPoint, state);
xOffset = CheckBoxRenderer.GetGlyphSize(e.Graphics, state).Width + 4;
}
else
{
RadioButtonState state = e.Item.Checked ? RadioButtonState.CheckedNormal : RadioButtonState.UncheckedNormal;
RadioButtonRenderer.DrawRadioButton(e.Graphics, glyphPoint, state);
xOffset = RadioButtonRenderer.GetGlyphSize(e.Graphics, state).Width + 4;
}
}
//add a 2 pixel buffer the match default behavior
Rectangle rec = new Rectangle(e.Bounds.X + 2 + xOffset, e.Bounds.Y + 2, e.Bounds.Width - 4, e.Bounds.Height - 4);
//TODO Confirm combination of TextFormatFlags.EndEllipsis and TextFormatFlags.ExpandTabs works on all systems. MSDN claims they're exclusive but on Win7-64 they work.
TextFormatFlags flags = TextFormatFlags.Left | TextFormatFlags.EndEllipsis | TextFormatFlags.ExpandTabs | TextFormatFlags.SingleLine;
//If a different tabstop than the default is needed, will have to p/invoke DrawTextEx from win32.
TextRenderer.DrawText(e.Graphics, e.SubItem.Text, e.Item.ListView.Font, rec, e.SubItem.ForeColor, flags);
}
开发者ID:J-F-B-M,项目名称:BrainSimulator,代码行数:60,代码来源:TaskForm.cs
示例2: lvObjects_DrawSubItem
private void lvObjects_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
this.columnName.Width = lvObjects.Width - 16*3 - 4;
if (e.SubItem.Tag != null)
{
if (e.Header == this.columnNetwork)
{
e.DrawBackground();
var imageRect = new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Height, e.Bounds.Height);
Image imgToDraw = e.SubItem.Tag.Equals(true) ? Resources.networkIconOn : Resources.networkIconOff;
e.Graphics.DrawImage(imgToDraw, imageRect);
e.Header.Width = 16;
}
else if (e.Header == this.columnPlayer)
{
e.DrawBackground();
var imageRect = new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Height, e.Bounds.Height);
Image imgToDraw = e.SubItem.Tag.Equals(true) ? Resources.playerIconOn : Resources.playerIconOff;
e.Graphics.DrawImage(imgToDraw, imageRect);
e.Header.Width = 16;
}
}
else
{
e.DrawDefault = true;
return;
}
}
开发者ID:SnoUweR,项目名称:iTunesSVKS-2,代码行数:30,代码来源:SettingsForm.cs
示例3: dataSelectionList_DrawSubItem
private void dataSelectionList_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
Color color;
switch (e.ColumnIndex)
{
case 2:
color = Color.FromArgb(int.Parse(e.SubItem.Text));
Rectangle rect = e.Bounds;
rect.Inflate(-4, -2);
using (SolidBrush brush = new SolidBrush(color))
{
e.Graphics.FillRectangle(brush, rect);
e.Graphics.DrawRectangle(Pens.Black, rect);
}
break;
case 3:
float x1 = e.SubItem.Bounds.X;
float x2 = e.SubItem.Bounds.X + e.SubItem.Bounds.Width;
float y = e.SubItem.Bounds.Y + e.SubItem.Bounds.Height / 2;
color = Color.FromArgb(int.Parse(e.Item.SubItems[2].Text));
float thickness = float.Parse(e.Item.SubItems[1].Text);
using (Pen pen = new Pen(color, thickness))
{
e.Graphics.DrawLine(pen, x1, y, x2, y);
}
break;
default:
e.DrawDefault = true;
break;
}
}
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:35,代码来源:StockIndicatorSelectorDialog.cs
示例4: Draw
public override void Draw(DrawListViewSubItemEventArgs e)
{
if (this.hot != Rectangle.Empty)
{
if (this.hot != e.Bounds)
{
this.ListView.Invalidate(this.hot);
this.hot = Rectangle.Empty;
}
}
if ((!this.DrawIfEmpty) && (string.IsNullOrEmpty(e.SubItem.Text)))
return;
Point mouse = e.Item.ListView.PointToClient(Control.MousePosition);
if ((this.ListView.GetItemAt(mouse.X, mouse.Y) == e.Item) && (e.Item.GetSubItemAt(mouse.X, mouse.Y) == e.SubItem))
{
ButtonRenderer.DrawButton(e.Graphics, e.Bounds, e.SubItem.Text, Font, true, PushButtonState.Hot);
this.hot = e.Bounds;
}
else
{
ButtonRenderer.DrawButton(e.Graphics, e.Bounds, e.SubItem.Text, Font, false, PushButtonState.Default);
}
}
开发者ID:feg-giessen,项目名称:videocommander,代码行数:26,代码来源:ListViewExtender.cs
示例5: 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:J-F-B-M,项目名称:BrainSimulator,代码行数:25,代码来源:NodeSelectionForm.cs
示例6: OnDrawSubItem
protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
{
e.DrawDefault = true;
base.OnDrawSubItem(e);
double d;
if (e.Item.BackColor != Color.MediumPurple)
{
if (e.Item.Index % 2 == 0) //theSubItemIndex����ָ��Ҫ�ػ����
{
//e.Item.BackColor = Color.FromArgb(247, 247, 247);
e.Item.BackColor = Color.Azure;
int count = e.Item.SubItems.Count - 1;
while (count >= 1)
{
e.Item.SubItems[count].BackColor = Color.Azure;
count--;
}
//e.Item.SubItems[2].BackColor = Color.FromArgb(247, 247, 247);
}
else
{
//e.Item.ForeColor = Color.;
}
}
}
开发者ID:harryho,项目名称:demo-fx-trading-platform-prototype,代码行数:27,代码来源:ManagedTreeView.cs
示例7: this_DrawSubItem
void this_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
if (e.SubItem is IOwnerDrawLVSubItem)
//描画をカスタマイズするサブアイテムの場合は描画を呼ぶ
((IOwnerDrawLVSubItem)e.SubItem).DrawSubItem(e);
else
//そうでなければシステムに描画を任せる
e.DrawDefault = true;
}
开发者ID:lscyane,项目名称:KCBr,代码行数:9,代码来源:ListViewEx.cs
示例8: OnDrawSubItem
protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
{
object o = ((OLVListItem) e.Item).RowObject;
if (o is TreePathReference)
{
TreePathReference r = (TreePathReference) o;
e.Item.ForeColor = ActiveGetter(r) ? ActiveForegroudColor : InactiveForegroudColor;
}
base.OnDrawSubItem(e);
}
开发者ID:applejian,项目名称:cyberduck,代码行数:10,代码来源:MulticolorTreeListView.cs
示例9: OnDrawSubItem
protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
{
if ( !this.ContainsFocus && !_HideSelection )
{
ListViewItemStates status = e.Item.Selected ? ListViewItemStates.Selected : e.ItemState;
base.OnDrawSubItem(new DrawListViewSubItemEventArgs(e.Graphics, e.Bounds, e.Item, e.SubItem, e.ItemIndex, e.ColumnIndex, e.Header, status));
}
else
base.OnDrawSubItem(e);
}
开发者ID:ischool-desktop,项目名称:MOD_Club.General.Zizhu,代码行数:10,代码来源:ListViewEX.cs
示例10: HandleDrawSubItem
private void HandleDrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
if (e.ItemIndex == -1)
return;
e.Graphics.FillRectangle(new SolidBrush(e.ItemState.HasFlag(ListViewItemStates.Selected) ? oRAColours.Colour_Item_BG_0 : oRAColours.Colour_BG_P0), e.Bounds.X, e.Bounds.Y, e.Bounds.Width - 1, e.Bounds.Height - 1);
if (e.Item.Text == "")
e.Graphics.DrawLine(new Pen(oRAColours.Colour_BG_P1), Columns[0].Width - 1, e.Bounds.Y, Columns[0].Width - 1, e.Bounds.Y + e.Bounds.Height);
else
e.Graphics.DrawLine(new Pen(oRAColours.Colour_BG_P1), e.Bounds.X - 1, e.Bounds.Y, e.Bounds.X - 1, e.Bounds.Y + e.Bounds.Height);
e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
e.Graphics.DrawString(e.SubItem.Text, oRAFonts.Font_SubDescription, e.ItemState.HasFlag(ListViewItemStates.Selected) ? new SolidBrush(oRAColours.Colour_Text_H) : new SolidBrush(oRAColours.Colour_Text_N), e.Bounds.Left + 22, e.Bounds.Top + e.Bounds.Height / 2 - e.Graphics.MeasureString(e.Item.Text, oRAFonts.Font_SubDescription).Height / 2);
}
开发者ID:smoogipooo,项目名称:osu-Replay-Analyzer,代码行数:12,代码来源:CustomListView.cs
示例11: OnDrawSubItem
protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
{
if (e.Item.Selected)
{
e.Graphics.FillRectangle(Brushes.Yellow, e.Bounds);
}
else
{
e.DrawBackground();
}
e.Graphics.DrawString(e.SubItem.Text, Font, Brushes.Black, e.Bounds);
}
开发者ID:HeatherTooill,项目名称:RegExpose,代码行数:13,代码来源:HighlightableListView.cs
示例12: OnDrawSubItem
protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
{
base.OnDrawSubItem(e);
if (e.ItemState == 0)
{
return;
}
if ((e.ItemState & ListViewItemStates.Selected) == ListViewItemStates.Selected)
e.SubItem.BackColor = System.Drawing.Color.LightSkyBlue;
else
{
ConfigData data = e.Item.Tag as ConfigData;
if (data != null && (data.HasTaskitem || data.IsAutRun))
{
e.SubItem.BackColor = System.Drawing.Color.Pink;
}
else if (e.ItemIndex % 2 != 0)
e.SubItem.BackColor = HVH_Ken_Modules.GlobalVar.Instanse.StyleColor;
else
e.SubItem.BackColor = this.BackColor;
}
e.DrawBackground();
using (StringFormat sf = new StringFormat())
{
HorizontalAlignment align = Columns[e.ColumnIndex].TextAlign;
if (align == HorizontalAlignment.Center)
sf.Alignment = StringAlignment.Center;
else if (align == HorizontalAlignment.Right)
sf.Alignment = StringAlignment.Far;
e.Graphics.DrawString(e.SubItem.Text, Font, new SolidBrush(ForeColor), e.Bounds, sf);
}
e.DrawFocusRectangle(e.Bounds);
if ((e.ItemState & ListViewItemStates.Focused) == ListViewItemStates.Focused)
{
if (this.FullRowSelect == false)
{
if (e.ColumnIndex == 0)
{
e.DrawFocusRectangle(e.Bounds);
}
}
else
e.DrawFocusRectangle(e.Bounds);
}
}
开发者ID:kener1985,项目名称:MyGitHubProj,代码行数:49,代码来源:MyListView.cs
示例13: RssListView_DrawSubItem
private void RssListView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
if (e.ColumnIndex == 1)
{
e.Graphics.FillRectangle(new SolidBrush(Color.Blue), e.Bounds);
}
else
{
//e.Graphics.DrawString(e.SubItem.Text, Font, Brushes.Red, e.Bounds);
e.DrawDefault = true;
//e.Graphics.DrawString(e.SubItem.Text,Font,Brushes.Black,e.Bounds);
}
}
开发者ID:metaburbia,项目名称:RssTray,代码行数:15,代码来源:RssListView.cs
示例14: OnDrawSubItem
protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
{
ImageListViewSubItem item = e.SubItem as ImageListViewSubItem;
if (item == null)
{
e.DrawDefault = true;
base.OnDrawSubItem(e);
}
else
{
using (e.Graphics)
item.Drawable.Draw(e.Graphics, e.Bounds);
}
}
开发者ID:AssassinUKG,项目名称:monotorrent,代码行数:15,代码来源:ImageListView.cs
示例15: OnDrawSubItem
protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
{
ListViewItem.ListViewSubItem oitem = e.Item.SubItems[e.ColumnIndex];
ProgressSubItem item = null;
if (oitem is ProgressSubItem)
item = (ProgressSubItem)oitem;
if (item != null && item.ShowProgress && item.ProgressMaxValue > 0)
{
double percent = (double)item.ProgressValue / (double)item.ProgressMaxValue;
if (percent > 1.0f)
percent = 1.0f;
Rectangle rect = item.Bounds;
Graphics g = e.Graphics;
//绘制进度条
Rectangle progressRect = new Rectangle(rect.X + 1, rect.Y + 3, rect.Width - 2, rect.Height - 5);
g.DrawRectangle(new Pen(new SolidBrush(Color.FromArgb(0x51, 0x51, 0x51)), 1), progressRect);
//绘制进度
int progressMaxWidth = progressRect.Width - 1;
int width = (int)(progressMaxWidth * percent);
if (width >= progressMaxWidth) width = progressMaxWidth;
g.FillRectangle(new SolidBrush(Color.FromArgb(0xa4, 0xa3, 0xa3)), new Rectangle(progressRect.X + 1, progressRect.Y + 1, width, progressRect.Height - 1));
if(item.ShowPercentOverflowProgress)
{
//绘制进度百分比
percent *= 100;
string percentText = string.Format("{0}% ", percent.ToString("F2"));
Size size = TextRenderer.MeasureText(percentText.ToString(), Font);
int x = (progressRect.Width - size.Width) / 2;
int y = (progressRect.Height - size.Height) / 2 + 3;
if (x <= 0) x = 1;
if (y <= 0) y = 1;
int w = size.Width;
int h = size.Height;
if (w > progressRect.Width) w = progressRect.Width;
if (h > progressRect.Height) h = progressRect.Height;
g.DrawString(percentText, this.Font, new SolidBrush(Color.Black), new Rectangle(rect.X + x, rect.Y + y, w, h));
}
}
else
{
e.DrawDefault = true;
base.OnDrawSubItem(e);
}
}
开发者ID:cheehwasun,项目名称:BaiduPCS_NET,代码行数:48,代码来源:ListViewProgress.cs
示例16: OnDrawSubItem
protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e) {
ListViewItem item = Items[e.ItemIndex];
if (item == null || !(item is HomuTactListViewItem)) {
e.DrawDefault = true;
return;
}
HomuTactListEntry entry = (item as HomuTactListViewItem).Entry;
Color texCol = Color.Black;
switch (entry.Behavior) {
case EHomuBehavior.Attack:
case EHomuBehavior.Attack1st:
case EHomuBehavior.AttackLast:
case EHomuBehavior.AttackWeak:
texCol = Color.Maroon;
break;
case EHomuBehavior.React:
case EHomuBehavior.React1st:
case EHomuBehavior.ReactLast:
texCol = Color.Violet;
break;
case EHomuBehavior.Avoid:
texCol = Color.Gray;
break;
case EHomuBehavior.Coward:
texCol = Color.Blue;
break;
}
SolidBrush drawBrush = new SolidBrush(texCol);
Point drawPoint = new Point(e.Bounds.X, e.Bounds.Y);
e.DrawBackground();
if (SelectedIndices.Contains(e.ItemIndex) == true)
e.Graphics.FillRectangle(Brushes.LightBlue, e.Bounds);
if (e.ColumnIndex == 0)
e.Graphics.DrawString(entry.ID.ToString(), new Font(Font, FontStyle.Bold), drawBrush, drawPoint);
else if (e.ColumnIndex == 1)
e.Graphics.DrawString(entry.Name, Font, drawBrush, drawPoint);
else if (e.ColumnIndex == 2)
e.Graphics.DrawString(entry.Behavior.ToString(), Font, drawBrush, drawPoint);
else if (e.ColumnIndex == 3 && entry.Behavior != EHomuBehavior.Avoid)
e.Graphics.DrawString(entry.Skill.ToString(), Font, drawBrush, drawPoint);
else if (e.ColumnIndex == 4 && entry.Behavior != EHomuBehavior.Avoid && entry.Skill != EHomuSkillUsage.NoSkill)
e.Graphics.DrawString(entry.Priority.ToString(), Font, drawBrush, drawPoint);
}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:47,代码来源:HomuTactListView.cs
示例17: DrawSubItemBackground
public void DrawSubItemBackground(object sender, DrawListViewSubItemEventArgs e)
{
Rectangle r = e.Bounds;
Brush b = Form.Skin.ListViewNormalBackBrush;
if(e.ItemIndex % 2 == 1)
b = Form.Skin.ListViewNormal2BackBrush;
if(e.Item.Selected)
b = Form.Skin.ListViewSelectedBackBrush;
if(e.Item.Focused)
b = Form.Skin.ListViewFocusedBackBrush;
e.Graphics.FillRectangle(b, r);
e.Graphics.DrawRectangle(Form.Skin.ListViewGridPen, r);
}
开发者ID:liftir,项目名称:airvpn-client,代码行数:19,代码来源:ListView.cs
示例18: 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
示例19: HandleCustomDraw
//.........这里部分代码省略.........
// .NET's handling of Tile view and let the underlying control
// do its stuff. Strangely, if the Tile view is
// completely owner drawn, those erasures don't happen.
if (this.View == View.Tile) {
if (this.OwnerDraw && this.ItemRenderer != null)
base.WndProc(ref m);
} else {
base.WndProc(ref m);
}
m.Result = (IntPtr)((int)m.Result | CDRF_NOTIFYPOSTPAINT | CDRF_NOTIFYPOSTERASE);
return true;
case CDDS_ITEMPOSTPAINT:
//System.Diagnostics.Debug.WriteLine("CDDS_ITEMPOSTPAINT");
if (this.Columns.Count > 0) {
OLVListItem olvi = this.GetItem((int)nmcustomdraw.nmcd.dwItemSpec);
if (olvi != null)
this.drawnItems.Add(olvi);
}
break;
case CDDS_SUBITEMPREPAINT:
//System.Diagnostics.Debug.WriteLine(String.Format("CDDS_SUBITEMPREPAINT ({0},{1})", (int)nmcustomdraw.nmcd.dwItemSpec, nmcustomdraw.iSubItem));
// There is a bug in the .NET framework which appears when column 0 of an owner drawn listview
// is dragged to another column position.
// The bounds calculation always returns the left edge of column 0 as being 0.
// The effects of this bug become apparent
// when the listview is scrolled horizontally: the control can think that column 0
// is no longer visible (the horizontal scroll position is subtracted from the bounds, giving a
// rectangle that is offscreen). In those circumstances, column 0 is not redraw because
// the control thinks it is not visible and so does not trigger a DrawSubItem event.
// To fix this problem, we have to detected the situation -- owner drawing column 0 in any column except 0 --
// trigger our own DrawSubItem, and then prevent the default processing from occuring.
// Are we owner drawing column 0 when it's in any column except 0?
if (!this.OwnerDraw)
return false;
int columnIndex = nmcustomdraw.iSubItem;
if (columnIndex != 0)
return false;
int displayIndex = this.Columns[0].DisplayIndex;
if (displayIndex == 0)
return false;
int rowIndex = (int)nmcustomdraw.nmcd.dwItemSpec;
OLVListItem item = this.GetItem(rowIndex);
if (item == null)
return false;
// OK. We have the error condition, so lets do what the .NET framework should do.
// Trigger an event to draw column 0 when it is not at display index 0
using (Graphics g = Graphics.FromHdc(nmcustomdraw.nmcd.hdc)) {
// Correctly calculate the bounds of cell 0
Rectangle r = item.GetSubItemBounds(0);
// We can hardcode "0" here since we know we are only doing this for column 0
DrawListViewSubItemEventArgs args = new DrawListViewSubItemEventArgs(g, r, item, item.SubItems[0], rowIndex, 0,
this.Columns[0], (ListViewItemStates)nmcustomdraw.nmcd.uItemState);
this.OnDrawSubItem(args);
// If the event handler wants to do the default processing (i.e. DrawDefault = true), we are stuck.
// There is no way we can force the default drawing because of the bug in .NET we are trying to get around.
System.Diagnostics.Trace.Assert(!args.DrawDefault, "Default drawing is impossible in this situation");
}
m.Result = (IntPtr)4;
return true;
case CDDS_SUBITEMPOSTPAINT:
//System.Diagnostics.Debug.WriteLine("CDDS_SUBITEMPOSTPAINT");
break;
// I have included these stages, but it doesn't seem that they are sent for ListViews.
// http://www.tech-archive.net/Archive/VC/microsoft.public.vc.mfc/2006-08/msg00220.html
case CDDS_PREERASE:
//System.Diagnostics.Debug.WriteLine("CDDS_PREERASE");
break;
case CDDS_POSTERASE:
//System.Diagnostics.Debug.WriteLine("CDDS_POSTERASE");
break;
case CDDS_ITEMPREERASE:
//System.Diagnostics.Debug.WriteLine("CDDS_ITEMPREERASE");
break;
case CDDS_ITEMPOSTERASE:
//System.Diagnostics.Debug.WriteLine("CDDS_ITEMPOSTERASE");
break;
}
return false;
}
开发者ID:ZlayaZhaba,项目名称:XervBackup,代码行数:101,代码来源:ObjectListView.cs
示例20: HistoryListView_DrawSubItem
void HistoryListView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
if (e.ItemIndex < 0) return;
//Console.WriteLine(e.ItemIndex + "-" + e.Bounds);
if (this.SelectedIndices.Contains(e.ItemIndex))
{
e.Graphics.FillRectangle(System.Drawing.Brushes.LightGray, e.Bounds);
ControlPaint.DrawFocusRectangle(e.Graphics, e.Item.Bounds);
}
else
{
e.DrawBackground();
}
// if this is the first column, we want to draw an icon as well
int newX = e.Bounds.Left;
if (e.ColumnIndex == 0)
{
// draw the icon
newX = newX + 20;
PastNotification pn = (PastNotification)e.Item.Tag;
if (pn != null)
{
System.Drawing.Image img = PastNotificationManager.GetImage(pn);
using (img)
{
if (img != null)
{
int x = e.Bounds.Left + 2;
int y = e.Bounds.Top;
e.Graphics.DrawImage(img, new System.Drawing.Rectangle(x, y, 16, 16));
}
}
}
}
// draw text
string text = e.SubItem.Text.Replace("\r", " - ");
System.Drawing.Rectangle rect = new System.Drawing.Rectangle(newX, e.Bounds.Top, e.Bounds.Right - newX, e.Item.Font.Height);
System.Drawing.StringFormat sf = new System.Drawing.StringFormat();
sf.Trimming = System.Drawing.StringTrimming.EllipsisCharacter;
sf.FormatFlags = System.Drawing.StringFormatFlags.NoClip | System.Drawing.StringFormatFlags.NoWrap;
System.Drawing.Color color = (e.ColumnIndex == 0 ? e.Item.ForeColor : System.Drawing.Color.FromArgb(System.Drawing.SystemColors.GrayText.ToArgb()));
System.Drawing.SolidBrush foreBrush = new System.Drawing.SolidBrush(color);
using (foreBrush)
{
//TextFormatFlags flags = TextFormatFlags.Default | TextFormatFlags.ExternalLeading | TextFormatFlags.GlyphOverhangPadding | TextFormatFlags.NoClipping | TextFormatFlags.EndEllipsis | TextFormatFlags.LeftAndRightPadding | TextFormatFlags.SingleLine;
//TextRenderer.DrawText(e.Graphics, text, e.SubItem.Font, rect, e.SubItem.ForeColor, System.Drawing.Color.Transparent, flags);
e.Graphics.DrawString(text,
e.SubItem.Font,
foreBrush,
rect,
sf);
}
}
开发者ID:iwaim,项目名称:growl-for-windows,代码行数:58,代码来源:HistoryListView.cs
注:本文中的System.Windows.Forms.DrawListViewSubItemEventArgs类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论