Tooltips for CheckedListBox items?

后端 未结 5 749
盖世英雄少女心
盖世英雄少女心 2021-01-17 10:20

Is there a straighforward way to set additional text to appear in a tooltip when a user\'s mouse is held over an item in a CheckedListBox?

What I would expect

5条回答
  •  佛祖请我去吃肉
    2021-01-17 10:44

    Run through your ListItems in your checkbox list of items and set the appropriate text as the item 'title' attribute, and it will display on hover...

    foreach (ListItem item in checkBoxList.Items)
                    { 
                        //Find your item here...maybe a switch statement or
                        //a bunch of if()'s
                        if(item.Value.ToString() == "item 1")
                        {
                            item.Attributes["title"] = "This tooltip will display when I hover over item 1 now, thats it!!!";
                        }
                        if(item.Value.ToString() == "item 2")
                        {
                            item.Attributes["title"] = "This tooltip will display when I hover over item 2 now, thats it!!!";
                        }
                    }
    

提交回复
热议问题