2010-04-28 6 views
21

के लिए टूलटिप स्थापित करने के लिए मैं ListView और निश्चित आकार के कुछ कॉलमकैसे एक ListViewItem

पाठ lenghth मैं स्तंभ में भरने स्तंभ
की निश्चित लंबाई इसलिए जब उपयोगकर्ता कि ListViewItem पर माउस टिकी हुई है से अधिक हो सकता, एक टूलटिप आइटम

मैंने कोशिश की

ListViewItem iListView = new ListViewItem("add"); 

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

लेकिन कोई उपयोग का विस्तार दिखाया जाना चाहिए

उत्तर

38

ListView की ShowItemToolTips संपत्ति को सत्य पर सेट करें।

+1

हाँ कि काम करता है, धन्यवाद एक बहुत – Gaddigesh

+0

ऐसा प्रतीत होता है टूलटिप्स भी एक अक्षरों की सीमा जब वास्तव में लंबे तार प्रदर्शित करने के लिए कोशिश कर रहा है। ऐसे कई समाधान हैं जो सूची दृश्य में टेक्स्ट प्रदर्शित करने के लिए 25 9 कॉलम सीमा को बाधित करते हैं (उदाहरण के लिए http://stackoverflow.com/questions/5559704/net-listview-max-number-of-characters-or-maximum-column-width- संभव-से-ओवी) या आप उपयोगकर्ता को चयनित लाइनों को कॉपी-पेस्ट कर सकते हैं। – valsidalv

4

उपयोग ListViewItem.ToolTipText संपत्ति

// 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

यह _exactly_ वह पहले से ही कर रहा है। – SLaks

+0

@ स्लक्स: मैंने जो लिंक जोड़ा है उससे एक स्निप करता है; बस मुझे और लाइनें जोड़नी चाहिए थीं। इंगित करने के लिए धन्यवाद। –

संबंधित मुद्दे