[英]How do I position the Image from the ListView at the left from the column?
問題:
我在第一列中有一個帶有圖像的 ListView。 但問題是圖像不是位於左側,而是位於中心位置很奇怪,因此您看不到完整的用戶名。
問題:
那么有沒有辦法把左邊的圖片改成position,這樣就可以正確看到用戶名了?
代碼:
添加 ListViewItem 的代碼
public void AddMessage(string from, string message)
{
ListViewItem item = new ListViewItem(new string[] {from, DateTime.Now.GetDateTimeFormats()[7], message});
item.ImageIndex = 0;
listView1.Items.Add(item);
}
在這里你可以嘗試兩種方法,一種
listView1.Columns["columnName"].TextAlign = HorizontalAlignment.Left;
或者您可以通過這種方式使用事件DrawSubItem
private void listView1_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
TextFormatFlags flags = TextFormatFlags.Left;
if (e.ColumnIndex == 0)
{
flags = TextFormatFlags.Right;
}
e.DrawText(flags);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.