Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a datagridview cell which can contain several clickable links?

Is there a way to have a column/cell in a DataGridView which can contain multiple links each of which is individually clickable?

Example mocked up in Excel:

enter image description here

like image 930
hawbsl Avatar asked Nov 20 '25 18:11

hawbsl


1 Answers

Have a look at the code for DataGridViewLinkCell class using a tool like ILSpy. I would imagine you'd need to create your own datagridviewcolumn, datagridviewcell and possibly your own editing control. (Build a Custom NumericUpDown Cell and Column for the DataGridView Control has a detailed example of this).

  • you'll need to override the Paint method to paint links horizontally.
  • You'll need to use the cell's font to create a new one with the Underline property set to true.
  • You'll also need to override the OnMouseMove to change the cursor when it's over the link.
  • You'll need to override the OnMouseDown to determine which link they clicked

Again, the DataGridViewLinkCell does all of these for a single link plus more, so I would use that code for the class as a starting point for your needs.

like image 171
Hasani Blackwell Avatar answered Nov 23 '25 07:11

Hasani Blackwell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!