private void _entryBoxSearchCriteria_Changed(object sender, EventArgs e) { _listStoreModelFilter.Refilter(); //Always set Cursor position to first record on filter, else we LOST Cursor, and it can Crash on Cursor dependent CRUD methods like UPDATE/DELETE TreeIter treeIter; _listStoreModelFilter.GetIterFirst(out treeIter); _treeView.SetCursor(_listStoreModelFilter.GetPath(treeIter), _treeView.Columns[0], false); _treeView.ScrollToCell(_listStoreModelFilter.GetPath(treeIter), _treeView.Columns[0], false, 0, 0); }
public void RebuildTable() { if ((null == model) || (null == items) || (null == table)) { iFolderViewGroup.log.Info("NULL Reference Exception: Object, model is -{0}-items is-{1}-table is -{2}-", model, items, table); return; // prevent null pointer exception } int numOfItems = model.IterNChildren(); if (numOfItems > 0) { int availableWidth = currentWidth - (int)(contentVBox.BorderWidth * 2) - (int)(table.BorderWidth * 2); int numOfColumns = availableWidth / ItemMaxWidth; if (numOfColumns < 1) { numOfColumns = 1; // Force at least one column } int numOfRows = numOfItems / numOfColumns; if ((numOfItems % numOfColumns) > 0) { numOfRows++; } bFirstTableBuild = false; /// /// Clear out the old items /// items.Clear(); foreach (Widget w in table.Children) { table.Remove(w); w.Destroy(); } table.Resize((uint)numOfRows, (uint)numOfColumns); int currentRow = 0; int currentColumn = 0; TreeIter iter; if (model.GetIterFirst(out iter)) { do { iFolderHolder holder = (iFolderHolder)model.GetValue(iter, 0); if (holder != null) { iFolderViewItem item = new iFolderViewItem(holder, this, iter, ItemMaxWidth); if (null == item) { iFolderViewGroup.log.Info("NULL Reference Exception: Object item is NULL"); return; //prevent null pointer exception } table.Attach(item, (uint)currentColumn, (uint)currentColumn + 1, (uint)currentRow, (uint)currentRow + 1, AttachOptions.Shrink | AttachOptions.Fill, 0, 0, 0); // Save off the item so we can quickly reference it later TreePath path = model.GetPath(iter); items[path.ToString()] = item; // Register for the click events item.LeftClicked += new EventHandler(OnItemLeftClicked); item.RightClicked += new EventHandler(OnItemRightClicked); item.DoubleClicked += new EventHandler(OnItemDoubleClicked); currentColumn = ((currentColumn + 1) % numOfColumns); if (currentColumn == 0) { currentRow++; } } } while (model.IterNext(ref iter)); } table.ShowAll(); } else { items.Clear(); foreach (Widget w in table.Children) { table.Remove(w); w.Destroy(); } } }