Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to edit a specific cell

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support
View previous topic :: View next topic  
Author Message
DaveRook



Joined: 10 Dec 2014
Posts: 4

PostPosted: Fri Dec 12, 2014 3:57 pm    Post subject: How to edit a specific cell Reply with quote

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
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5002

PostPosted: Sat Dec 13, 2014 7:05 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
DaveRook



Joined: 10 Dec 2014
Posts: 4

PostPosted: Mon Dec 15, 2014 8:15 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group