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 

Checkbox column does not repaint well when form is resized

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



Joined: 15 Feb 2006
Posts: 7
Location: San Diego

PostPosted: Tue Mar 03, 2009 9:53 pm    Post subject: Checkbox column does not repaint well when form is resized Reply with quote

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
View user's profile Send private message
WolfenSteed



Joined: 15 Feb 2006
Posts: 7
Location: San Diego

PostPosted: Tue Mar 03, 2009 9:55 pm    Post subject: checkbox rendering Reply with quote

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
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Mar 03, 2009 9:58 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Thu Mar 05, 2009 1:34 am    Post subject: Reply with quote

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
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