protected void OnChildRowCountNeeded(TreeDataGridViewChildRowCountNeededEventArgs e) { if (ChildRowCountNeeded == null) { throw new NullReferenceException("no handler for ChildRowCountNeeded event"); } ChildRowCountNeeded(this, e); }
/// <summary> /// Show child rows /// </summary> /// <param name="index">Which row to expand</param> /// <param name="maxDepth">How far down to expand</param> /// <returns></returns> protected int expand(int index, int maxDepth) { var rowInfo = expandedRowList[index]; if (!rowInfo.HasChildRows || rowInfo.ExpandedChildRows.Count > 0 && maxDepth == 0) { return(0); // row already expanded, nothing to do } int rowsAdded = 0; if (rowInfo.ExpandedChildRows.Count == 0) { if (!rowInfo.ChildRowCount.HasValue) { var e = new TreeDataGridViewChildRowCountNeededEventArgs(rowInfo.RowIndexHierarchy); OnChildRowCountNeeded(e); rowInfo.ChildRowCount = e.ChildRowCount; } var childRowList = new List <ExpandedRowList>(rowInfo.ChildRowCount.Value); for (int j = 0; j < rowInfo.ChildRowCount; ++j) { //get the content of the child row and add it to list to be inserted var childRowInfo = new ExpandedRowList(rowInfo.RowIndexHierarchy, j); var cellValueEventArgs = new TreeDataGridViewCellValueEventArgs(0, childRowInfo.RowIndexHierarchy); CellValueNeeded(this, cellValueEventArgs); childRowInfo.ChildRowCount = cellValueEventArgs.ChildRowCount; childRowInfo.HasChildRows = cellValueEventArgs.HasChildRows; childRowList.Add(childRowInfo); } //insert new rows into table rowInfo.ExpandedChildRows = childRowList; expandedRowList.InsertRange(index + 1, childRowList); rowsAdded = childRowList.Count; } //If more expansion is needed recurse back to the begining if (maxDepth > rowInfo.RowIndexHierarchy.Count) { for (int j = 0; j < rowInfo.ChildRowCount; ++j) { rowsAdded += expand(index + rowsAdded + 1 - rowInfo.ChildRowCount.Value + j, maxDepth); } } return(rowsAdded); }
protected void OnChildRowCountNeeded(TreeDataGridViewChildRowCountNeededEventArgs e) { if (ChildRowCountNeeded == null) throw new NullReferenceException("no handler for ChildRowCountNeeded event"); ChildRowCountNeeded(this, e); }
private void treeDataGridView_ChildRowCountNeeded (object sender, TreeDataGridViewChildRowCountNeededEventArgs e) { var parentRow = GetRowFromRowHierarchy(e.RowIndexHierarchy); if (parentRow is PeptideSpectrumMatchRow) { lock (session) parentRow.ChildRows = getPeptideSpectrumMatchScoreRows(parentRow as PeptideSpectrumMatchRow); e.ChildRowCount = parentRow.ChildRows.Count; return; } var childFilter = getChildFilter(parentRow); e.ChildRowCount = PeptideSpectrumMatchRow.GetQueryCount(session, childFilter); }
/// <summary> /// Show child rows /// </summary> /// <param name="index">Which row to expand</param> /// <param name="maxDepth">How far down to expand</param> /// <returns></returns> protected int expand (int index, int maxDepth) { var rowInfo = expandedRowList[index]; if (!rowInfo.HasChildRows || rowInfo.ExpandedChildRows.Count > 0 && maxDepth == 0) return 0; // row already expanded, nothing to do int rowsAdded = 0; if (rowInfo.ExpandedChildRows.Count == 0) { if (!rowInfo.ChildRowCount.HasValue) { var e = new TreeDataGridViewChildRowCountNeededEventArgs(rowInfo.RowIndexHierarchy); OnChildRowCountNeeded(e); rowInfo.ChildRowCount = e.ChildRowCount; } var childRowList = new List<ExpandedRowList>(rowInfo.ChildRowCount.Value); for (int j = 0; j < rowInfo.ChildRowCount; ++j) { //get the content of the child row and add it to list to be inserted var childRowInfo = new ExpandedRowList(rowInfo.RowIndexHierarchy, j); var cellValueEventArgs = new TreeDataGridViewCellValueEventArgs(0, childRowInfo.RowIndexHierarchy); CellValueNeeded(this, cellValueEventArgs); childRowInfo.ChildRowCount = cellValueEventArgs.ChildRowCount; childRowInfo.HasChildRows = cellValueEventArgs.HasChildRows; childRowList.Add(childRowInfo); } //insert new rows into table rowInfo.ExpandedChildRows = childRowList; expandedRowList.InsertRange(index + 1, childRowList); rowsAdded = childRowList.Count; } //If more expansion is needed recurse back to the begining if (maxDepth > rowInfo.RowIndexHierarchy.Count) for (int j = 0; j < rowInfo.ChildRowCount; ++j) rowsAdded += expand(index + rowsAdded + 1 - rowInfo.ChildRowCount.Value + j, maxDepth); return rowsAdded; }