实施drawsubitem时,如何仍在列表视图中突出显示一行? [英] How can I still highlight a line in listview when implementing drawsubitem?

查看:118
本文介绍了实施drawsubitem时,如何仍在列表视图中突出显示一行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为listview控件实现了以下内容:

I have implemented the following for a listview control:

private void transactionGrid_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;
      }

      CultureInfo culture;
      DateTimeStyles styles;
      DateTime dateResult;

      culture = CultureInfo.CreateSpecificCulture("fr-FR");
      styles = DateTimeStyles.None;
      if (DateTime.TryParse(e.SubItem.Text, culture, styles, out
 dateResult))
      {
         sf.Alignment = StringAlignment.Far;
         Brush b;
         b = ((e.Item.Tag as Transaction).Cleared) ? Brushes.Black : Brushes.Red;
         e.Graphics.DrawString(_Globals.myDateStr(dateResult), transactionGrid.Font, b, e.Bounds, sf);
         return;
      }
      e.DrawText(flags);
   }
}


当我这样做时,我会丢失所选行上的突出显示
我有FullRowSelect == true和hideslection = false

我该如何做drawsubitem并仍然突出显示整行?


[edit]添加了代码块[/edit]


When I do this I lose the highlight on the selected line
I have FullRowSelect==true and hideslection=false

How can I do the drawsubitem and still highlight the whole row please?


[edit]Code block added[/edit]

推荐答案

曾经看过Canvas吗?这种和平为您提供了绘制粉红色/绿色,加粗的&¦¦italian等所需的所有内容.
Ever had a look to Canvas? This peace gives you all the stuff you Need to draw pink/green, bold &¦¦italian and much more.


这篇关于实施drawsubitem时,如何仍在列表视图中突出显示一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆