View previous topic :: View next topic |
Author |
Message |
DaveRook
Joined: 10 Dec 2014 Posts: 4
|
Posted: Fri Dec 12, 2014 3:57 pm Post subject: How to edit a specific cell |
|
|
Hi
I am using VirtualTree and am trying to edit a cell value via C#
I can use EditFirstCellInFocusRow() which works perfectly.
However, I can only see
EditFirstCellInFocusRow()
EditLastCellInFocusRow()
As you can see, this is a direct way to access the first and last cell in the row, but in this case, I have 3 cells in my row.
I can't find anything similar to
EditCell(3) //where it accepts an int to indicate the index
So, if I have 3 columns (3 cells) in my selected row, how do I start the edit for the middle cell?
Thank you all in advance. |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Sat Dec 13, 2014 7:05 am Post subject: |
|
|
If your SelectionMode is set to SelectionMode.Cell then you can just set the SelectedColumn property to the column you want to edit and then call EditCurrentCellInFocusRow.
If you aren't using Cell selection mode then it is a bit trickier and you will probably need to derive from Virtual Tree to implement a method that does what you want (by calling the protected method GetCellWidget to get the widget for the cell you want to edit and then calling StartEdit(widget) to edit the cell). _________________ Infralution Support |
|
Back to top |
|
|
DaveRook
Joined: 10 Dec 2014 Posts: 4
|
Posted: Mon Dec 15, 2014 8:15 am Post subject: |
|
|
Right, worked it out so I will share in case it helps others.
We have SelectionMode.FullRow
I added
[code]
private void virtualTree1_CellMouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button != System.Windows.Forms.MouseButtons.Right)
return;
var cellWidget = (sender as CellWidget);
if (cellWidget == null)
return;
this._selectedCell = new SelectedCell(cellWidget.Row, cellWidget.Column); //selectedCell is my own class, with 2 properties
}[/code]
Now, I know the column, so when a user rights click on the cell in question, I have a reference. They then choose rename in the context menu which fires
[code]
private void Rename(object sender, EventArgs e)
{
if (this._selectedCell == null)
throw new NotImplementedException("Not initialized correctly");
this.virtualTree1.SelectionMode = Infralution.Controls.VirtualTree.SelectionMode.Cell;
this._selectedCell.Column.Selectable = true;
this.virtualTree1.SelectedColumn = this._selectedCell.Column;
this.virtualTree1.EditCurrentCellInFocusRow();
this._selectedCell.Column.Selectable = false;
this.virtualTree1.SelectionMode = Infralution.Controls.VirtualTree.SelectionMode.FullRow;
}[/code] |
|
Back to top |
|
|
|