LU
luokun
September 8, 2009 10:08 AM UTC
set to editable already known.
rectangle area select and cell select ,copy & patse not know yet.
GK
Ganesan K
Syncfusion Team
September 9, 2009 07:13 AM UTC
Hi Luokun,
Thanks for using Syncfusion products.
You can use the below code to enable any type of Selection.
treeGrid.EnableNodeSelection = false;
treeGrid.Model.Options.AllowSelection = GridSelectionFlags.Any;
For copy paste you have the two options.
you can CopyPaste the Cell Information by set the CopyPasteOption as below
treeGrid.Model.Options.CopyPasteOption = CopyPaste.CopyCellData | CopyPaste.CutCell | CopyPaste.PasteCell;
you can CopyPaste the Text Information by set the CopyPasteOption as below
treeGrid.Model.Options.CopyPasteOption = CopyPaste.CopyText | CopyPaste.CutText | CopyPaste.PasteText;
you can also need to set ActivateCurrentCellBehavior as DblClickOnCell to enable the CopyPaste feature.
treeGrid.Model.Options.ActivateCurrentCellBehavior = GridCellActivateAction.DblClickOnCell
Please let me know if you need any more detail.
Thanks
Ganesan
LU
luokun
September 10, 2009 02:28 AM UTC
Very thanks for your reply,now I have some new question.
1.I set treeGrid's ShowRowHeader is true,but the rowheader hasn't row number like grid control,and when I drag mouse on the rowheader although, row can't be selected like grid control.
2.Selected cell's color too light,how to set the color?
3.I want let row can be drag & drop into another row let be the row's child row,can I do it?
LU
luokun
September 10, 2009 06:03 AM UTC
I know the reason.
If EnableNodeSelection set to false,row can't be selected,but cell and rectangle area can be selected.
Conversely if EnableNodeSelection set to true,row can be selected,but cell and rectangle area can't be selected.
So,let row and cell and rectangle area all can be selected is impossible?
LU
luokun
September 10, 2009 06:28 AM UTC
I mearn like Dashboard Sample Browser's "Excel Like Selections Demo" or "Grid Control Selections Demo".
GK
Ganesan K
Syncfusion Team
September 14, 2009 09:42 AM UTC
Hi Luokun,
You can set the row number for row header by listen the Model_QueryCellInfo as below
void Model_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
if (e.Cell.ColumnIndex == 0 && e.Cell.RowIndex != 0)
{
e.Style.CellValue = e.Cell.RowIndex;
}
}
You can set the Selected Cell's color using the below code.
treeGrid.Model.Options.HighlightSelectionBackground = Brushes.LightBlue;
treeGrid.Model.Options.DrawSelectionOptions = GridDrawSelectionOptions.ReplaceBackground;
You can select cell and Rectangle area by setting the treeGrid.EnableNodeSelection as false.
You can also select the row by ctrl + clicking on the rowheader.
I have attached the workaround sample for the above in the below location.
http://www.syncfusion.com/uploads/redirect.aspx?file=GTC_Sam2_b209ec2b.zip&team=development I have prepared the sample for row drag and drop, and attached the sample in the below location, Please check it out.
http://www.syncfusion.com/uploads/redirect.aspx?file=GTC_Sam_1f1af3c.zip&team=developmentPlease let me know if you need any more details.
Thanks
Ganesan
LK
luo kun
September 15, 2009 03:20 AM UTC
Very thanks for your example,a very useful help.
Now I have a new question,how to add a new row in Grid Tree Control programatically?
LK
luo kun
September 16, 2009 02:30 AM UTC
Sorry,I have a another question.
Base on your GTC_Sam example,I add a little code imitate your code to implement right button drag and drop.
While drag use right button,after the mouse moved a little,the drop event be responsed ,not like left button until button unleash the drop event be response.
Please check the attached file.
GTC_Sam_4057ba80.zip
GK
Ganesan K
Syncfusion Team
September 16, 2009 10:28 AM UTC
Hi Luokun,
To drag, the mouse needs to be captured, which can only be achieved when the left mouse button is down.Because of this the drop event be responsed immediately when drag use right button, after the mouse moved a little,but we can add below code in the Drop event to make it work properly. Please check it out this in the below sample.
if (e.KeyStates == DragDropKeyStates.RightMouseButton)
{
return;
}
I have prepared the sample for add a new row in Grid Tree Control programatically.Please download the sample in the below location and check it out.
http://www.syncfusion.com/uploads/redirect.aspx?file=GTC-AddNewRow_36686ec4.zip&team=developmentPlease let me know if you need any more details.
Thanks
Ganesan
LK
luo kun
September 17, 2009 05:32 AM UTC
Maybe this is the last question.
I try to use drag&drop copy a row to be another row's child row,but on runtime a error occured,message is :
Property accessor 'ID' on object 'Syncfusion.Windows.Controls.Grid.GridTreeNode' threw the following exception:'Object does not match target type.'
Please check the attached source.
DragDrop_e39b5df2.zip
LK
luo kun
September 18, 2009 05:01 AM UTC
On example GTC_Sam2,click or silde row header can select row(s). At this time, click the grid tree control,treeGrid.SelectedNodes.Count is 0.(use PreviewMouseLeftButtonDown event)
how to get the selected row(s) by row header?
P.S.MouseLeftButtonDown event can't be responsed.
CB
Clay Burch
Syncfusion Team
September 18, 2009 01:28 PM UTC
There are events on the SelectedNodes collection that you can use to get the action of the selected change. treeGrid.SelectedNodes.Changing is a canceable event that occurs before the collection is modified. You can check the e.Action member to see exactly what modification is about to take place.
Additionally, SelectedNodes is derived from ObservableCollection so it has the SelectedNodes.CollectionChanged event that is inherited from its base class. This is strictly a notification event that can be used to react to changes in teh collection. Here is some sample code for this Changed event.
//subscribe to the event...
treeGrid.SelectedNodes.CollectionChanged += new NotifyCollectionChangedEventHandler(SelectedNodes_CollectionChanged);
//some event handler code
void SelectedNodes_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
switch (e.Action)
{
case NotifyCollectionChangedAction.Add:
Console.WriteLine(e.Action);
break;
default:
break;
}
}
}
LK
luo kun
September 21, 2009 06:11 AM UTC
9/17's message now is the only one question,the error
"Property accessor 'ID' on object 'Syncfusion.Windows.Controls.Grid.GridTreeNode' threw the following exception:'Object does not match target type.'"
can't be resolve.I need help.
CB
Clay Burch
Syncfusion Team
September 21, 2009 12:13 PM UTC
Try making these code chnages to your treeGrid_Drop method.
//Change this line
//GridTreeNode treeNode = new GridTreeNode(parentNode.Level + 1, CurrentNode, false, parentNode);
//to
GridTreeNode treeNode = new GridTreeNode(parentNode.Level + 1, CurrentNode.Item, false, parentNode);
CurrentNode.ParentNode.ChildNodes.Remove(CurrentNode); //add this line
((Employee)(CurrentNode.Item)).ReportsTo = ((Employee)(parentNode.Item)).ID; //add this line
The first change is to pass the CurrentNode.Item instead of CurrentNode in the GridTreeNode constructor call.
The second change removes the item being dropped from the its original position.
The third change adjusts the ReportsTo property of the original object so that it properly points to its new parent.
LK
luo kun
September 24, 2009 02:57 AM UTC
Now still have two small question.
1.I would like to hold the selected range when drag & drop, even after drop finish.
For it,I add some code in treeGrid_PreviewMouseLeftButtonDown and treeGrid_PreviewMouseMove function.But can't be work.I watch treeGrid.Model.SelectedRanges's value at line 137 by breakpoint,the value is correct but selected range background not be shown.
2.Now on my code, after drag & drop,the mouse become like "viscous".only move the mouse will change the selected range, the correctly should be pressing the left mouse button moves the selected range can be changed.I don't know what's wrong.
please check the attached file.
GTC_Sam_6b8b6c1a.zip
CB
Clay Burch
Syncfusion Team
September 24, 2009 07:55 PM UTC
Here is your sample back with a SelectionsChanging event handler added. This handler is used to lock the selections when a drag is about to occur.
GTC_Sam_835cb234.zip
LK
luo kun
September 25, 2009 02:30 AM UTC
hello,your sample in here cause exception on runtime,the message is follow:
Cannot create instance of 'Window1' defined in assembly 'TreeGridMinimalSample, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Exception has been thrown by the target of an invocation. Error in markup file 'Window1.xaml' Line 1 Position 10.
what different?
CB
Clay Burch
Syncfusion Team
September 25, 2009 08:03 AM UTC
The sample is probably using a diferent version than what you have. Try removing all the Syncfusion references from the project, and then re-add them so the project is referring to the version that you have on your system. After this, do a rebuild all.
CB
Clay Burch
Syncfusion Team
September 25, 2009 08:28 AM UTC
One other thing to try. Put a stop on this line in the Window's constructor.
treeGrid.Model.SelectionChanging += new GridSelectionChangingEventHandler(Model_SelectionChanging);
Then try running the application. If it hits the stop, try stepping through this line. If the exception is raised at this point, then try moving that line down into the ModelLoaded event handler to see if that will avoid this issue.
The version I am using differs from earlier versions in that it allows you to subscribe to Model events in the Windows constructor (before the Model is actually loaded). The earlier versions require the Model to be loaded before you can subscribe to the events.