public int GetSubItemAt(int x, int y, out ListViewItem item, out bool canEdit) { canEdit = false; item = this.GetItemAt(x, y); if (item != null) { int[] order = GetColumnOrder(); Rectangle lviBounds; int subItemX; lviBounds = item.GetBounds(ItemBoundsPortion.Entire); subItemX = lviBounds.Left; for (int i = 0; i < order.Length; i++) { TemplateColumnHeader columnHeader = this.Columns[order[i]]; if (x < subItemX + columnHeader.Width) { canEdit = columnHeader.CanEdit; return(columnHeader.Index); } subItemX += columnHeader.Width; } } return(-1); }
private void TemplateListView_ColumnClick(object sender, ColumnClickEventArgs e) { ListView listView = sender as ListView; if (listView != null) { TemplateColumnHeader sorter = listView.Columns[e.Column] as TemplateColumnHeader; if (sorter != null) { foreach (ColumnHeader header in this.Columns) { header.ImageKey = null; } if (listView.Sorting == SortOrder.None) { listView.Sorting = SortOrder.Ascending; this.Columns[e.Column].ImageKey = "up"; } else if (listView.Sorting == SortOrder.Ascending) { listView.Sorting = SortOrder.Descending; this.Columns[e.Column].ImageKey = "down"; } else { listView.Sorting = SortOrder.Ascending; this.Columns[e.Column].ImageKey = "up"; } sorter.Column = e.Column; this.ListViewItemSorter = sorter; } } }
public void Add(string text, string template) { TemplateColumnHeader col = new TemplateColumnHeader(); col.Text = text; col.Template = template; List.Add(col); }
public void Add(string template) { TemplateColumnHeader header = new TemplateColumnHeader(); header.Text = template; header.Template = template; List.Add(header); }
public void Add(string text, string template, int width) { TemplateColumnHeader col = new TemplateColumnHeader(); col.Text = text; col.Template = template; col.Width = width; List.Add(col); }
public void Add(string template, int width) { TemplateColumnHeader header = new TemplateColumnHeader(); header.Text = template; header.Template = template; header.Width = width; List.Add(header); }
public void Add(TemplateColumnHeader Item) { List.Add(Item); }