in c#, i have a listview control. i want the text fields in ONE of the columns to get truncated at the beginning instead of the end.
i.e. i want the text fields in column 2 to read:
...name1
...name2
...name3
instead of
filena...
filena...
filena...
Try
void Form1_Load(object sender, EventArgs e)
{
listView1.OwnerDraw = true;
listView1.DrawColumnHeader +=listView1_DrawColumnHeader;
listView1.DrawSubItem+=listView1_DrawSubItem;
}
private void listView1_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
{
e.DrawText();
}
private void listView1_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
e.DrawText(TextFormatFlags.Right);
}
if it's just one specific column that you would like to see this behavior say col index = 5 then try
private void listView1_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
if (e.ColumnIndex == 5)
{
e.DrawText(TextFormatFlags.Right);
}
else
{
e.DrawText();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With