View previous topic :: View next topic |
Author |
Message |
mwe
Joined: 08 Dec 2005 Posts: 15
|
Posted: Wed Mar 22, 2006 12:23 pm Post subject: How to access Row and Column in InitializeControl? |
|
|
I'm trying to accomplish the following using VirtualTree that we purchased for our projects.
I have a number of resources displayed in my main column in a tree. These resources can participate in activities. Activities are represented by columns that are added and removed as activities are created or destroyed. I’d like to illustrate the use of a resource during and activity by having a checkbox ticked for that resource in the activity column. It would be nice if I could do something like this in InitializeControl for the Checkbox editor I defined.
Code: | private void cellEditorCheckBox_InitializeControl(object sender, CellEditorInitializeEventArgs e)
{
CheckBox checkboxControl = e.Control as CheckBox;
checkboxControl.DataBindings.Add("CheckState", /* DataSourceAsFunctionOf(Row,Column) */, "Allocated");
} |
This would (I hope) initialize each checkbox with the correct value as well as update the datasource when the user ticks/unticks the checkbox in the column for a specific row.
However, I have not been able to figure out how to get the row and column that the editor is being initialized for. How would I do that? _________________ Kind regards
Magnus Werner, System Architect
------------------------------------------
Saab Training Systems AB |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Wed Mar 22, 2006 10:11 pm Post subject: |
|
|
You don't actually need to use InitializeControl to achieve what you are trying to do. If you are using Object Binding or Data Set Binding then when you use a CheckBoxControl as an editor for column/cell which is bound to a boolean field then Virtual Tree will do this automatically for you ie when the CheckedChanged event is fired by the control Virtual Tree will call the SetValueForCell method which uses the cell binding to set the new value back into the data source
If you are using programmatic binding then you have to handle the GetCellData event (or override OnGetCellData) to set the CellValue to based on your data source and then handle the SetCellValue event (or override SetValueForCell) to set the new value back into your data source. See the FolderTree class in the File Browser sample - it does this. _________________ Infralution Support |
|
Back to top |
|
|
mwe
Joined: 08 Dec 2005 Posts: 15
|
Posted: Thu Mar 23, 2006 5:12 pm Post subject: |
|
|
Thanks for the fast answer. I was planning on using Object Binding and what you say make sense when you think about it. I have to apply an Adaptor pattern to give the items a boolean property that can be bound per column. _________________ Kind regards
Magnus Werner, System Architect
------------------------------------------
Saab Training Systems AB |
|
Back to top |
|
|
|