View previous topic :: View next topic |
Author |
Message |
WolfenSteed
Joined: 15 Feb 2006 Posts: 7 Location: San Diego
|
Posted: Tue Mar 03, 2009 9:53 pm Post subject: Checkbox column does not repaint well when form is resized |
|
|
I have added a checkbox editor column with it's DisplayMode value set to CellEditorDisplayMode.Always. When I resize the form/VirtualTree, the checkboxes do not always repaint correctly. Sometimes the checked boxes repaint without the checks and sometimes the checkbox does not repaint at all. _________________ Walt :)
Nothing is too small to know, and nothing is too big to attempt. |
|
Back to top |
|
|
WolfenSteed
Joined: 15 Feb 2006 Posts: 7 Location: San Diego
|
Posted: Tue Mar 03, 2009 9:55 pm Post subject: checkbox rendering |
|
|
I forgot to add that I am using VirtualTree version 3.11.2, but that we have seen this behavior on previous versions. _________________ Walt :)
Nothing is too small to know, and nothing is too big to attempt. |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue Mar 03, 2009 9:58 pm Post subject: |
|
|
I've just looked at the File Browser sample project which uses DisplayMode.Always checkboxes - but it doesn't seem to exhibit the problem you are seeing.
Can you maybe email a sample project the demonstrates the problem to support@infralution.com _________________ Infralution Support |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Thu Mar 05, 2009 1:34 am Post subject: |
|
|
Thanks for the sample project - that quickly identified what the issue is (at least in part). Your sample code has not bound the column containing the checkboxes to any data. Virtual Tree is completely data driven (bound), it does not store the state behind the editor but relies on your data model to do this. This means that if you don't bind data to the column containing the checkboxes then the state of the checkbox will not be persisted properly. Virtual Tree will create and reuse editor controls as you scroll and or expand the tree. If you haven't data bound the column then the state of the checkbox will be lost.
Often with checkboxes you may not wish to bind them to a property of your actual objects and instead wish to maintain the check state seperately in a list of the checked items. You can do this by handling the GetCellValue and SetCellValue events specially for the column eg
Code: |
private ArrayList checkedItems = new ArrayList();
private void virtualTree1_GetCellData(object sender, GetCellDataEventArgs e)
{
if (e.Column == this.colCheck)
{
e.CellData.Value = checkedItems.Contains(e.Row.Item);
}
else
{
// use the default binding to do the work
//
RowBinding binding = virtualTree1.GetBindingForRow(e.Row);
if (binding != null)
{
binding.GetCellData(e.Row, e.Column, e.CellData);
}
}
}
private void virtualTree1_SetCellValue(object sender, SetCellValueEventArgs e)
{
if (e.Column == this.colCheck)
{
if ((bool)e.NewValue)
checkedItems.Add(e.Row.Item);
else
checkedItems.Remove(e.Row.Item);
}
else
{
// use the default binding to do the work
//
RowBinding binding = virtualTree1.GetBindingForRow(e.Row);
binding.SetCellValue(e.Row, e.Column, e.OldValue, e.NewValue);
}
} |
The folder browser sample project also illustrates doing this.
I'm not seeing any issue with checkboxes not repainting at all. If you are seeing this then it may be a display driver issue. _________________ Infralution Support |
|
Back to top |
|
|
|