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 

Using data binding change icon based on cell content

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



Joined: 18 May 2012
Posts: 4

PostPosted: Tue Oct 29, 2013 6:12 am    Post subject: Using data binding change icon based on cell content Reply with quote

I have a tree where I have some data stored in a DataTable. I use data binding to get the data into the virtual tree. I also use the design time editor to set an icon for each of my datatables (after using auto generate)

Say I have a table like:

[row_id[name][state]
0 one 1
1 two 2
2 three 1

What I would like to do is have the tree change the icon based on the value in [state]. I display both image and text in the cell can't see how to change the icon, just for this cell to a new one based on the 'state'
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Oct 29, 2013 7:04 am    Post subject: Reply with quote

You have to handle the GetRowData event and set the image/icon programmatically as shown below:

Code:
      private void _virtualTree_GetRowData(object sender, GetRowDataEventArgs e)
        {
            // get the default binding for the given row and use it to populate the row data
            //
            RowBinding binding = _virtualTree.GetRowBinding(e.Row);
            binding.GetRowData(e.Row, e.RowData);

            // now assign the icon/image based on your program condition
            //
            if (e.Row.Item is OrderDataSet.CustomersRow)
            {
                OrderDataSet.CustomersRow customer = e.Row.Item as OrderDataSet.CustomersRow;             

                if (customer.ContactName.StartsWith("A"))
                {
                    e.RowData.Image = _myImage;
                }
            }
        }


This code is a modification to the DataSetBrowser sample and sets the image for all customers with ContactName starting with A to a different image.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
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