Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set the prompt content ToolTip of a cell by DataGridView

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "DataGridView how to set the prompt content of the cell ToolTip", in the daily operation, I believe that many people have doubts on the question of how to set the prompt content of the cell ToolTip in DataGridView. The editor consulted all kinds of materials and sorted out a simple and easy-to-use method of operation. I hope it will be helpful for everyone to answer the question of "how to set the prompt content of the cell in DataGridView". Next, please follow the editor to study!

The ToolTip property is used to set the prompt when the mouse moves over the cell.

In the case of DataGridView.ShowCellToolTips=True, the ToolTip of the cell can be expressed. For cells that are narrow and cannot be fully displayed, ToolTip can display the necessary information.

Example 1: set the ToolTip content of a cell

/ / set the prompt content of the first column in the second row this.dgv_PropDemo [0,1] .ToolTipText = "the contents of this cell cannot be modified"

Running effect:

Example 2: set the ToolTip content of the cell in the column header:

/ / set the ToolTipthis.dgv_PropDemo.Columns [3] .ToolTipText of the fourth column header = "only male or female can be entered in this row"

Running effect:

Example 3: set the ToopTip content of the cell in the header:

/ / set the ToopTipthis.dgv_PropDemo.Rows [0] .HeaderCell.ToolTipText of the first line header = "the contents of this row cell cannot be modified"

Running effect:

CellToopTipTextNeeded event

When setting the ToolTip of a batch of cells, it is relatively inefficient to specify one by one, so you can take advantage of the CellToopTipTextNeeded event. This event is also raised when the ToopTipText of a cell changes. However, when the DataSource of the DataGridView is specified and VirualMode=True, the event is not raised.

Private void dgv_PropDemo_CellToolTipTextNeeded (object sender, DataGridViewCellToolTipTextNeededEventArgs e) {/ / Mouse displays the prompt message if (e.ColumnIndex = = 2) {e.ToolTipText = "column:" + e.ColumnIndex.ToString () + ", row:" + e.RowIndex.ToString ();}} when the mouse is over the cell in the third column.

Running effect:

At this point, on the "DataGridView how to set the cell prompt content ToolTip" on the end of the study, I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report