ListView and Column Margin :: C#
-
Hello, How do you set the margin (text) of a column of a ListView. For example: |Column0 | Column1| | | | I am referring simply to the text margin of a column. Given that you have to derive a class from ListView, what function do you override to set the margin or to draw the text based on a different margin? Thanks, Kuphryn
-
Hello, How do you set the margin (text) of a column of a ListView. For example: |Column0 | Column1| | | | I am referring simply to the text margin of a column. Given that you have to derive a class from ListView, what function do you override to set the margin or to draw the text based on a different margin? Thanks, Kuphryn
You must override
WndProc
and handle Windows messages for the header control (which are passed to their parent control's window, which is the List-View common control, whichListView
encapsulates). You could handle theNM_CUSTOMDRAW
message (sent using aWM_NOTIFY
message, actually) and draw your text that way, perhaps extending theListView
control to provide a margin property of some sort (or just hard-code it, depending on what you need the control for).Microsoft MVP, Visual C# My Articles
-
You must override
WndProc
and handle Windows messages for the header control (which are passed to their parent control's window, which is the List-View common control, whichListView
encapsulates). You could handle theNM_CUSTOMDRAW
message (sent using aWM_NOTIFY
message, actually) and draw your text that way, perhaps extending theListView
control to provide a margin property of some sort (or just hard-code it, depending on what you need the control for).Microsoft MVP, Visual C# My Articles