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 

Making a header span two columns

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



Joined: 13 Dec 2006
Posts: 4

PostPosted: Wed Dec 13, 2006 5:36 pm    Post subject: Making a header span two columns Reply with quote

I wished to make two fixed width columns look like a single column. This is due to the fact that I have two properties I wish to data-bind, one is a bool that I will link to a check box, the other is a string that I want to look like a label next to the check box.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Dec 13, 2006 10:50 pm    Post subject: Reply with quote

I assume that the label is intrinsically linked to the checkbox value eg when checked the label might be "Open" when unchecked it might be "Closed". Is this the case?

If this is the case the simplest solution is to derive your own checkbox control that changes the label text when the Checked value changes. Then you can simply use your derived control as an editor and bind to the checked value.

It is also possible to derive your own HeaderWidget to modify the creation and layout of the ColumnHeaderWidgets - but this is a good deal more complicated - particularly if you want to support movable columns.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
ianr



Joined: 13 Dec 2006
Posts: 4

PostPosted: Thu Dec 14, 2006 11:13 am    Post subject: Custom Controls, UniversalEditBox, UITypeEditor etc Reply with quote

Both the label and the colour of the label is dependant on the state of ALL the check boxes above the item in the tree, as well as the value of the item itself. (I don’t want the logic that works out the text for the label in the UI code; it will need testing with nUnit!)

As the check box has to be “tri-state” and I need custom images for the 3 states sub-classing the checkbox control may well be the way to go. However I will have to change it’s data binding to bind to a type other then Boolean.

I see that your data binding is a bit more flexible then the standard winforms data binding. Do you have a write up on what is different? E.g. does my control have to hook all the data-binding events to update itself, or do you do that for me and set the “ValueProperty” on the control each time that the business object fires INofityPropertyChanged? In other words which sections of “Data Binding with Windows Froms 2.0 by Drain Noyes” should I be reading?

Can I data bind more then one property on a control to different properties on my business object?

Would I be better off using your UniversalEditBox and defining my own UITypeEditor etc? What are the trade offs between using a custom winforms control and using a UITypeEditor, including runtime costs?
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Thu Dec 14, 2006 10:07 pm    Post subject: Reply with quote

Quote:
I see that your data binding is a bit more flexible then the standard winforms data binding. Do you have a write up on what is different? E.g. does my control have to hook all the data-binding events to update itself, or do you do that for me and set the “ValueProperty” on the control each time that the business object fires INofityPropertyChanged? In other words which sections of “Data Binding with Windows Froms 2.0 by Drain Noyes” should I be reading?


See the sections in the help documentation on Object Data Binding and Programmatic Data Binding. Virtual Tree binds to the Data Source (and child collections) using the IBindingList interface. This means it will automatically update the displayed values when the ListChanged event is fired. This can occur when the list changes or an item within the list is changed (the event argument provides this information).

Unlike data binding for many controls Virtual Tree also provides a lower level programmatic interface that allows you full control over the data the tree is bound to.

My feeling is that you want to implement a custom control (tri-state check box and label) that uses an Enum to specify the possible states of the control. Then you probably want to use the virtual tree programmatic binding interface to calculate the enum value for each row and return this. To do this you handle the GetCellData event something like below:

Code:
private void _valuesTree_GetCellData(object sender, GetCellDataEventArgs e)
{
    // use the default binding for most data
    //
    RowBinding binding = _valuesTree.GetBindingForRow(e.Row);
    binding.GetCellData(e.Row, e.Column, e.CellData);

    // calculate the cell value for the TriState column programmatically
    //
    if (e.Column is this.colTriState && row.Item is MyItemType)
   {
        MyItemType myItem = row.Item as MyItemType;

        MyEnum myEnum;

        // calculate the value of your tristate enum here
 
        e.Value = myEnum;       
    }
}

_________________
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