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 access Row and Column in InitializeControl?

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



Joined: 08 Dec 2005
Posts: 15

PostPosted: Wed Mar 22, 2006 12:23 pm    Post subject: How to access Row and Column in InitializeControl? Reply with quote

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



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Mar 22, 2006 10:11 pm    Post subject: Reply with quote

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



Joined: 08 Dec 2005
Posts: 15

PostPosted: Thu Mar 23, 2006 5:12 pm    Post subject: Reply with quote

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
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