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 

Binding a column to an object property that requires a param

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



Joined: 06 Jul 2009
Posts: 2

PostPosted: Mon Jul 06, 2009 2:34 pm    Post subject: Binding a column to an object property that requires a param Reply with quote

Hi...I have a need to add columns on the fly, which was easy enough, but I'm having troubles binding the new columns to my object. I typically bind each column to a property on my object but in this case, the property requires a passed parameter. Is there any way to bind a column to a property that requires a parameter? I don't get any error messages but the get method for that property is never called.

Thanks in advance for your response.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Mon Jul 06, 2009 10:48 pm    Post subject: Reply with quote

You will need use programmatic binding (rather than object binding) for this property. To do this you handle the GetCellData event. You can still use the object bindings to handle other properties.

The code below shows an example, assuming your object type is MyItem and the column you are binding to is called "colProblemMethod":

Code:
private void _virtualTree_GetCellData(object sender, GetCellDataEventArgs e)
{
    // get the default binding for the given row and use it to populate the cell data
    //
    RowBinding binding = _virtualTree.GetRowBinding(e.Row);
    binding.GetCellData(e.Row, e.Column, e.CellData);

    if (e.Row.Item is MyItem && e.Column == this.colProblemMethod)
    {
        MyItem myItem = e.Row.Item as MyItem;
        e.CellData.Value = myItem.ProblemMethod("foo");
    }
 }


Another alternative, since you are doing things on the fly, may be to create your own RowBinding class (probably derived from ObjectRowBinding)
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
jimcegelski



Joined: 06 Jul 2009
Posts: 2

PostPosted: Tue Jul 07, 2009 7:46 pm    Post subject: Reply with quote

Thanks very much...the code you provided worked perfectly.
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