Windows Develop Bookmark and Share   
 index > Windows Forms Designer > I want to have the first column in the ListView as a LinkLabel in Windows Forms.
 

I want to have the first column in the ListView as a LinkLabel in Windows Forms.

Hi All,

I want to have the first columnof my ListView as a LinkLabel in Windows Forms. I want my listview to have a linklabel or a hyperlink in 1 of the columns of ListView coloumn as shown below.

listview
________________
col 1col 2col 3
________________
row1row1row1
________________
row2 row2row2
________________
row3row3row3


Please, let me know if you know how to get this?

Thanks,
sankar

sankar sv
sarusankk  Thursday, February 26, 2009 3:45 PM

Hi Sankar,

I suggest that you draw the items in the ListView by yourself so that you can mimic the LinkLabel text. To do this, set the OwnerDraw property of the ListView to true and handle the DrawColumnHeader, DrawItem and DrawSubItem events of the ListView.

You can use the following line of code to draw a text with a underline:
Graphics.DrawString(e.Item.Text, new Font(this.Font, FontStyle.Underline), Brushes.Black, e.Bounds);

If you want to click the "LinkLabel" in the ListView, handle the MouseClick event of the ListView and in the event handler, check if the "LinkLabel" is clicked.

Hope this helps.

If you have any question, please feel free to let me know.

Sincerely,
Linda Liu

Linda Liu  Monday, March 02, 2009 11:02 AM
Not supported by WIndows Form Designer. Ask in theWindows Forms Data Controls and Databindingforum for alternatives.
MSMVP VC++
Sheng Jiang 蒋晟  Friday, February 27, 2009 11:52 PM

Hi Sankar,

I suggest that you draw the items in the ListView by yourself so that you can mimic the LinkLabel text. To do this, set the OwnerDraw property of the ListView to true and handle the DrawColumnHeader, DrawItem and DrawSubItem events of the ListView.

You can use the following line of code to draw a text with a underline:
Graphics.DrawString(e.Item.Text, new Font(this.Font, FontStyle.Underline), Brushes.Black, e.Bounds);

If you want to click the "LinkLabel" in the ListView, handle the MouseClick event of the ListView and in the event handler, check if the "LinkLabel" is clicked.

Hope this helps.

If you have any question, please feel free to let me know.

Sincerely,
Linda Liu

Linda Liu  Monday, March 02, 2009 11:02 AM

You can use google to search for other answers

Custom Search

More Threads

• Winforms control appearance is different in the Visual Studio form designer than at run time. .Net3.5 C#
• Tooltip blocks control properties!
• When I open win form app project via VS.NET, controls will be bigger...
• PropertyGrid & UITypeEditor
• Can't access instance.Name of UserControl in IDE
• Validation With Tab Pages
• Adding a new windows form from my own custom wizard
• User Control (text box), Null values, Formatting
• exception when opening complex C# form in design mode
• How to manage event handlers ofthe controls created in runtime