Replies
0
Here is a sample form.
- Click on a cell in the second row of the grid (not in the currently active row).
- Press Shift+Space to select the row. (The row is now selected and active).
- Press Shift+ Down key.
- Next row is selected but the first row is no longer selected.
public partial class Form1 : Form
{
public class SampleData
{
public int Id { get; set; }
public string Description { get; set; }
public SampleData(int id, string description)
{
Id = id;
Description = description;
}
}
private UltraGrid grid;
private List dataToBind;
public Form1()
{
InitializeComponent();
grid = new UltraGrid();
this.Controls.Add(grid);
grid.Dock = DockStyle.Fill;
grid.KeyDown += Grid_KeyDown;
dataToBind = new List ()
{
new SampleData(1, "Sample Item 1"),
new SampleData(2, "Sample Item 2"),
new SampleData(3, "Sample Item 3"),
new SampleData(4, "Sample Item 4"),
new SampleData(5, "Sample Item 5"),
new SampleData(6, "Sample Item 6"),
new SampleData(7, "Sample Item 7"),
new SampleData(8, "Sample Item 8"),
};
grid.DataSource = dataToBind;
}
private void Grid_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Space && e.Modifiers == Keys.Shift)
{
UltraGridRow row = grid.ActiveRow;
grid.ActiveCell = null; // Just for kicks
grid.ActiveRow = null; // Just for kicks
grid.ActiveRow = row;
grid.Selected.Rows.Add(row);
//grid.PerformAction(UltraGridAction.ToggleRowSel);
}
if (e.KeyCode == Keys.A && e.Modifiers == Keys.Control)
{
grid.Selected.Rows.AddRange((UltraGridRow[])grid.Rows.All);
grid.Selected.Rows[0].Activate();
}
}
}