我需要显示我ListViewItems的整个文本(不截断) [英] I need to display the entire Text of my ListViewItems (not truncated)

查看:338
本文介绍了我需要显示我ListViewItems的整个文本(不截断)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我显示ListViewItems,在ListView内的ListView组分类,都出现只是他们的Text属性,在那个(即使他们是在一个特定集团的唯一项目,还有亩,画面真实公顷截断地产提供)。

The ListViewItems I am displaying, categorized within ListView Groups in a ListView, are showing just their Text property, and truncated at that (even if they are the only item in a particular Group, and there are acres and hectares of screen real estate available).

我想他们确实显示其Text属性,但在其整体性,不会被截断。

I would like them to indeed display their Text property, but in its entirety, not truncated.

我分配ListViewItem的Text属性是这样的:

I am assigning the ListViewItem text property this way:

public LegacyApplication(String AAppName, String ATitle, String ADesc, String AIconFileName, String APathOfExe) {
  . . .
  base.Text = ATitle;
  . . .
}

我是什么做错了或者没有做对吗?有没有一些财产,我不知道,这将控制文本对ListViewItem的外观?

What am I doing wrong or failing to do right? Is there some property I'm unaware of that will control the appearance of the Text on the ListViewItem?

推荐答案

Windows资源管理器也为修整文本的工具提示,它同样采用了ListView控件。您可以通过处理MouseMove事件,并使用ListView.GetItemAt(...),找出鼠标正在哪个项目模仿它的行为。或者您可以使用ItemMouseHover事件,但是我发现的MouseMove更人性化的用户没有真正徘徊,等待提示弹出....

Windows Explorer also sets a Tooltip for trimmed text and it also uses a ListView control. You can imitate its behavior by handling the MouseMove event and using the ListView.GetItemAt(...) to find out which item the mouse is moving on. Alternatively you can use the ItemMouseHover event , however I found MouseMove to be more user friendly as the user does not have to actually hover and wait for the tooltip to popup ....

我用下面的逻辑来模仿Windows资源管理器的行为(此示例只是一个草案,并可能包含错误):

I used the following logic to imitate Windows explorer behaviour (this sample is only a draft and might contain errors):

     //get the item at the current mouse location.
     ListViewItem item = myListView.GetItemAt(e.X, e.Y);
     if (item != null)
     {
        using (Graphics graphics = this.myListView.CreateGraphics())
        {
           var itemTextWidth = graphics.MeasureString(item.Text, item.Font).Width;
           if (itemTextWidth > myListView.Width)
           {
              if (!item.Equals(itemsToolTip.Tag) && !itemsToolTip.Active)
              {
                 //Set the tooltip , tag it with the item and set it as active ... 
              }
              // Adjacent ' text trimmed' list view items.  
              else if (!item.Equals(itemsToolTip.Tag))
              {
                 //set the tooltip as none active.
              }
           }
           else//None trimmed list view items.
           {
              //clear the tooltip and set it as none active
           }
        }
     }
     else
     {
        //clear the tooltip and set it as none active
     }
  }

这篇关于我需要显示我ListViewItems的整个文本(不截断)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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