2010-04-28 13 views
21

tengo ListView y algunas columnas de tamaño fijoCómo establecer información sobre herramientas para un ListViewItem

la lenghth texto lleno yo, en la columna puede exceder la longitud fija de la columna
de modo que cuando el usuario se apoya el ratón sobre ese ListViewItem, un texto de ayuda se debe mostrar la expansión del elemento

probé

ListViewItem iListView = new ListViewItem("add"); 

iListView.ToolTipText = "Add Expanded"; 
myListView.Items.Add(iListView); 

Pero ningún uso

Respuesta

38

Establezca la propiedad ShowItemToolTips de ListView en verdadero.

+1

Sí que funciona, muchas gracias – Gaddigesh

+0

Al parecer, la información sobre herramientas también tienen un límite de caracteres cuando se trata de mostrar las cadenas muy largas. Hay varias soluciones que eluden el límite de 259 columnas para mostrar texto dentro de ListView (por ejemplo, http://stackoverflow.com/questions/5559704/net-listview-max-number-of-characters-or-maximum-column-width- posible-a-ov) o puede dejar que el usuario copie y pegue las líneas seleccionadas. – valsidalv

4

Uso ListViewItem.ToolTipText Propiedad

// Declare the ListView. 
private ListView ListViewWithToolTips; 
private void InitializeItemsWithToolTips() 
{ 

    // Construct and set the View property of the ListView. 
    ListViewWithToolTips = new ListView(); 
    ListViewWithToolTips.Width = 200; 
    ListViewWithToolTips.View = View.List; 

    // Show item tooltips. 
    ListViewWithToolTips.ShowItemToolTips = true; 

    // Create items with a tooltip. 
    ListViewItem item1WithToolTip = new ListViewItem("Item with a tooltip"); 
    item1WithToolTip.ToolTipText = "This is the item tooltip."; 
    ListViewItem item2WithToolTip = new ListViewItem("Second item with a tooltip"); 
    item2WithToolTip.ToolTipText = "A different tooltip for this item."; 

    // Create an item without a tooltip. 
    ListViewItem itemWithoutToolTip = new ListViewItem("Item without tooltip."); 

    // Add the items to the ListView. 
    ListViewWithToolTips.Items.AddRange(new ListViewItem[]{item1WithToolTip, 
     item2WithToolTip, itemWithoutToolTip}); 

    // Add the ListView to the form. 
    this.Controls.Add(ListViewWithToolTips); 
    this.Controls.Add(button1); 
} 
+0

Eso es _exactly_ lo que ya está haciendo. – SLaks

+0

@SLaks: Eso es un recorte del enlace que agregué; solo que debería haber agregado más líneas. Gracias por señalar. –

Cuestiones relacionadas