|
@@ -179,7 +179,7 @@ namespace Terminal.Gui {
|
|
|
selectedColumn = Table == null ? 0 : Math.Min (Table.Columns.Count - 1, Math.Max (0, value));
|
|
|
|
|
|
if(oldValue != selectedColumn)
|
|
|
- OnSelectedCellChanged();
|
|
|
+ OnSelectedCellChanged(new SelectedCellChangedEventArgs(Table,oldValue,SelectedColumn,SelectedRow,SelectedRow));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -190,12 +190,12 @@ namespace Terminal.Gui {
|
|
|
get => selectedRow;
|
|
|
set {
|
|
|
|
|
|
- var oldValue = selectedColumn;
|
|
|
+ var oldValue = selectedRow;
|
|
|
|
|
|
selectedRow = Table == null ? 0 : Math.Min (Table.Rows.Count - 1, Math.Max (0, value));
|
|
|
|
|
|
if(oldValue != selectedRow)
|
|
|
- OnSelectedCellChanged();
|
|
|
+ OnSelectedCellChanged(new SelectedCellChangedEventArgs(Table,SelectedColumn,SelectedColumn,oldValue,selectedRow));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -217,7 +217,7 @@ namespace Terminal.Gui {
|
|
|
/// <summary>
|
|
|
/// This event is raised when the selected cell in the table changes.
|
|
|
/// </summary>
|
|
|
- public event Action<EventArgs> SelectedCellChanged;
|
|
|
+ public event Action<SelectedCellChangedEventArgs> SelectedCellChanged;
|
|
|
|
|
|
/// <summary>
|
|
|
/// Initialzies a <see cref="TableView"/> class using <see cref="LayoutStyle.Computed"/> layout.
|
|
@@ -715,9 +715,9 @@ namespace Terminal.Gui {
|
|
|
/// <summary>
|
|
|
/// Invokes the <see cref="SelectedCellChanged"/> event
|
|
|
/// </summary>
|
|
|
- protected virtual void OnSelectedCellChanged()
|
|
|
+ protected virtual void OnSelectedCellChanged(SelectedCellChangedEventArgs args)
|
|
|
{
|
|
|
- SelectedCellChanged?.Invoke(new EventArgs());
|
|
|
+ SelectedCellChanged?.Invoke(args);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -853,4 +853,61 @@ namespace Terminal.Gui {
|
|
|
X = x;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Defines the event arguments for <see cref="TableView.SelectedCellChanged"/>
|
|
|
+ /// </summary>
|
|
|
+ public class SelectedCellChangedEventArgs : EventArgs
|
|
|
+ {
|
|
|
+ /// <summary>
|
|
|
+ /// The current table to which the new indexes refer. May be null e.g. if selection change is the result of clearing the table from the view
|
|
|
+ /// </summary>
|
|
|
+ /// <value></value>
|
|
|
+ public DataTable Table {get;}
|
|
|
+
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// The previous selected column index. May be invalid e.g. when the selection has been changed as a result of replacing the existing Table with a smaller one
|
|
|
+ /// </summary>
|
|
|
+ /// <value></value>
|
|
|
+ public int OldCol {get;}
|
|
|
+
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// The newly selected column index.
|
|
|
+ /// </summary>
|
|
|
+ /// <value></value>
|
|
|
+ public int NewCol {get;}
|
|
|
+
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// The previous selected row index. May be invalid e.g. when the selection has been changed as a result of deleting rows from the table
|
|
|
+ /// </summary>
|
|
|
+ /// <value></value>
|
|
|
+ public int OldRow {get;}
|
|
|
+
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// The newly selected row index.
|
|
|
+ /// </summary>
|
|
|
+ /// <value></value>
|
|
|
+ public int NewRow {get;}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Creates a new instance of arguments describing a change in selected cell in a <see cref="TableView"/>
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="t"></param>
|
|
|
+ /// <param name="oldCol"></param>
|
|
|
+ /// <param name="newCol"></param>
|
|
|
+ /// <param name="oldRow"></param>
|
|
|
+ /// <param name="newRow"></param>
|
|
|
+ public SelectedCellChangedEventArgs(DataTable t, int oldCol, int newCol, int oldRow, int newRow)
|
|
|
+ {
|
|
|
+ Table = t;
|
|
|
+ OldCol = oldCol;
|
|
|
+ NewCol = newCol;
|
|
|
+ OldRow = oldRow;
|
|
|
+ NewRow = newRow;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|