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 

CheckListBox as editor in VirtualTree

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



Joined: 28 Jun 2007
Posts: 1

PostPosted: Thu Jun 28, 2007 6:36 pm    Post subject: CheckListBox as editor in VirtualTree Reply with quote

I would like to use a CheckListBox as a cell editor. This list box would contain multiple items and support multiple selection. I can't figure out how to get the CheckedItemCollection property back from the editor control. Anyone have any hints?

Thanks,
Erik
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Fri Jun 29, 2007 12:39 am    Post subject: Reply with quote

You need to add event handlers to the CellEditor SetControlValue and GetControlValue events. In these you map the CheckedItems to and from the data bound to the column. You will also need to handle the InitializeControl event to set up the items in the checked list. For example:

Code:
private void checkedListEditor_GetControlValue(object sender, CellEditorGetValueEventArgs e)
{
    CheckedListBox clb = e.Control as CheckedListBox;
    IList values = e.Value as IList;
    foreach (object checkedItem in CheckedItems)
    {
        values.Add(checkedItem);
    }
}

private void checkedListEditor_SetControlValue(object sender, CellEditorSetValueEventArgs e)
{
    CheckedListBox clb = e.Control as CheckedListBox;
    IList values = e.Value as IList;
    foreach (object value in values)
    {
        int index = clb.Items.IndexOf(value);
        if (index != -1)
        {
           clb.SetItemChecked(index, true);
        }
    }
}

private void checkedListEditor_InitializeControl(object sender, CellEditorInitializeEventArgs e)
{
    CheckedListBox clb = e.Control as CheckedListBox;
    clb.Items.Clear();
    clb.Items.Add("Sydney");
    clb.Items.Add("New York");
    clb.Items.Add("London");
    clb.Items.Add("Berlin");
}


This assumes you have bound the column to a property that returns a list of the checked Items (in this case strings of city names).

I would also set the following properties on the CheckedListBox:

IntegralHeight = false;
CheckOnClick = true;

You will also need to set the height for the row to be sufficient to display the list.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Ger83



Joined: 15 Sep 2009
Posts: 5
Location: Pretoria, South Africa

PostPosted: Wed Apr 11, 2012 1:07 pm    Post subject: Reply with quote

This post was a lot of help for me to use a CheckedListBox control as an cell editor.

Quote:
You will also need to set the height for the row to be sufficient to display the list.


Could you please tell me how would I set the row height programatically when the control is displayed as is quoted above?
Back to top
View user's profile Send private message Visit poster's website
Ger83



Joined: 15 Sep 2009
Posts: 5
Location: Pretoria, South Africa

PostPosted: Wed Apr 11, 2012 2:39 pm    Post subject: Reply with quote

Ger83 wrote:
This post was a lot of help for me to use a CheckedListBox control as an cell editor.

Quote:
You will also need to set the height for the row to be sufficient to display the list.


Could you please tell me how would I set the row height programatically when the control is displayed as is quoted above?


So what I've done is registered to the tree's GetRowData event and set

Code:
e.RowData.AutoFitHeight = true;


But this does not change the row's height to fit the CheckedListBox control.

Any help?
Back to top
View user's profile Send private message Visit poster's website
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Thu Apr 12, 2012 12:03 am    Post subject: Reply with quote

AutoFitHeight only resizes based on text contained within the cell. It does not resize based on the size of displayed Editor control. Usually the Editor control is resized to fit the size of the cell (depending on the values of the CellEditor.UseCellWidth and CellEditor.UseCellHeight properties).

You will need to set the height of the row manually by setting the RowData.Height value (with AutoFitHeight false).
_________________
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