public static ctrl_TableList clearRows(this ctrl_TableList tableList)
 {
     return((ctrl_TableList)tableList.invokeOnThread(
                () => {
         tableList.getListViewControl().Items.Clear();
         return tableList;
     }));
 }
 public static ctrl_TableList sort(this ctrl_TableList tableList, SortOrder sortOrder)
 {
     return((ctrl_TableList)tableList.invokeOnThread(
                () =>
     {
         tableList.listView().Sorting = sortOrder;
         return tableList;
     }));
 }
 public static ctrl_TableList resize(this ctrl_TableList tableList)
 {
     return((ctrl_TableList)tableList.invokeOnThread(
                () =>
     {
         tableList.listView().AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
         return tableList;
     }));
 }
 public static ctrl_TableList selectFirst(this ctrl_TableList tableList)
 {
     return((ctrl_TableList)tableList.invokeOnThread(
                () => {
         var listView = tableList.getListViewControl();
         listView.SelectedIndices.Clear();
         listView.SelectedIndices.Add(0);
         return tableList;
     }));
 }
 public static ctrl_TableList set_ColumnWidth(this ctrl_TableList tableList, int columnNumber, int width)
 {
     return((ctrl_TableList)tableList.invokeOnThread(
                () => {
         var listView = tableList.getListViewControl();
         //if (listView.Columns.size()>columnNumber)
         tableList.getListViewControl().Columns[columnNumber].Width = width;
         return tableList;
     }));
 }
 public static ListViewItem selected(this ctrl_TableList tableList)
 {
     return((ListViewItem)tableList.invokeOnThread(
                () => {
         if (tableList.listView().SelectedItems.Count > 0)
         {
             return tableList.listView().SelectedItems[0];
         }
         return null;
     }));
 }
 public static ctrl_TableList set_ColumnAutoSizeForLastColumn(this ctrl_TableList tableList)
 {
     return((ctrl_TableList)tableList.invokeOnThread(
                () => {
         var listView = tableList.getListViewControl();
         if (listView.Columns.size() > 0)
         {
             listView.Columns[listView.Columns.size() - 1].Width = -2;
         }
         return tableList;
     }));
 }
 public static object tag(this ctrl_TableList tableList)
 {
     return((object)tableList.invokeOnThread(
                () => {
         var selectedItem = tableList.selected();
         if (selectedItem.notNull())
         {
             return selectedItem.Tag;
         }
         return null;
     }));
 }
 public static ListViewItem lastRow(this ctrl_TableList tableList)
 {
     return((ListViewItem)tableList.invokeOnThread(
                () =>
     {
         var listView = tableList.listView();
         if (listView.Items.size() > 0)
         {
             return listView.Items[listView.Items.size() - 1];
         }
         return null;
     }));
 }
 public static List <List <string> > values(this ctrl_TableList tableList)
 {
     return((List <List <string> >)tableList.invokeOnThread(
                () =>
     {
         var values = new List <List <string> >();
         foreach (var row in tableList.rows())
         {
             values.Add(row.values());
         }
         return values;
     }));
 }
 // ListViewItem
 public static List <ListViewItem> items(this ctrl_TableList tableList)
 {
     return((List <ListViewItem>)tableList.invokeOnThread(
                () =>
     {
         var items = new List <ListViewItem>();
         foreach (ListViewItem item in tableList.getListViewControl().Items)
         {
             items.Add(item);
         }
         return items;
     }));
 }
 //Column(s)
 public static ctrl_TableList add_Columns(this ctrl_TableList tableList, List <string> columnNames)
 {
     return((ctrl_TableList)tableList.invokeOnThread(
                () =>
     {
         ListView listView = tableList.getListViewControl();
         listView.Columns.Clear();
         listView.AllowColumnReorder = true;
         foreach (var columnName in columnNames)
         {
             listView.Columns.Add(columnName);
         }
         return tableList;
     }));
 }
 public static ctrl_TableList onDoubleClick_get_Row(this ctrl_TableList tableList, Action <ListViewItem> callback)
 {
     tableList.invokeOnThread(
         () => {
         tableList.listView().DoubleClick += (sender, e)
                                             => {
             var selectedRow = tableList.selected();
             if (selectedRow.notNull())
             {
                 O2Thread.mtaThread(() => callback(selectedRow));
             }
         };
     });
     return(tableList);
 }
 public static ListViewItem add_ListViewItem(this ctrl_TableList tableList, List <string> rowData)
 {
     return((ListViewItem)tableList.invokeOnThread(
                () => {
         var listView = tableList.getListViewControl();
         var listViewItem = new ListViewItem();
         if (rowData.Count > 0)
         {
             listViewItem.Text = rowData[0];             // hack because SubItems starts adding on the 2nd Column :(
             rowData.RemoveAt(0);
             listViewItem.SubItems.AddRange(rowData.ToArray());
             listView.Items.Add(listViewItem);
         }
         return listViewItem;
     }));
 }
 public static ctrl_TableList set_ColumnsWidth(this ctrl_TableList tableList, bool lastColumnShouldAutoSize, params int[] widths)
 {
     return((ctrl_TableList)tableList.invokeOnThread(
                () => {
         var listView = tableList.getListViewControl();
         for (var i = 0; i < widths.Length; i++)
         {
             listView.Columns[i].Width = widths[i];
         }
         if (lastColumnShouldAutoSize)
         {
             tableList.set_ColumnAutoSizeForLastColumn();
         }
         return tableList.set_ColumnAutoSizeForLastColumn();
     }));
 }
 //very similar to the code in add_Row (prob with that one is that it doens't return the new ListViewItem object
 public static ctrl_TableList add_Row <T>(this ctrl_TableList tableList, T _objectToAdd, Func <List <string> > getRowData)
 {
     return((ctrl_TableList)tableList.invokeOnThread(
                () => {
         var rowData = getRowData();
         if (rowData.Count > 0)
         {
             var listView = tableList.getListViewControl();
             var listViewItem = new ListViewItem();
             listViewItem.Text = rowData[0];             // hack because SubItems starts adding on the 2nd Column :(
             rowData.RemoveAt(0);
             listViewItem.SubItems.AddRange(rowData.ToArray());
             listView.Items.Add(listViewItem);
             listViewItem.Tag = _objectToAdd;             // only difference with main add_Row
         }
         return tableList;
     }));
 }
 public static ctrl_TableList onDoubleClick <T>(this ctrl_TableList tableList, Action <T> callback)
 {
     tableList.invokeOnThread(
         () => {
         tableList.listView().DoubleClick += (sender, e)
                                             => {
             var selectedRows = tableList.listView().SelectedItems;
             if (selectedRows.size() == 1)
             {
                 var selectedRow = selectedRows[0];
                 if (selectedRow.Tag.notNull() && selectedRow.Tag is T)
                 {
                     O2Thread.mtaThread(() => callback((T)selectedRow.Tag));
                 }
                 ;
             }
         };
     });
     return(tableList);
 }
 //misc
 public static ctrl_TableList title(this ctrl_TableList tableList, string title)
 {
     tableList.invokeOnThread(() => tableList._Title = title);
     return(tableList);
 }