View previous topic :: View next topic |
Author |
Message |
WaqasK
Joined: 21 Oct 2006 Posts: 32
|
Posted: Sun Nov 16, 2008 10:04 pm Post subject: Row resize event? |
|
|
Hi,
I was wondering if there was any event that is called when a row header is resized? I would like to keep a track of row widths so that they can be automatically saved each time a change is made. So the next time a user launches the application the row widths they specified earlier are displayed.
Thanks,
Waqas |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue Nov 18, 2008 6:18 am Post subject: |
|
|
No there isn't an event for this. You'd need to override the the VirtualTree.SetUserRowHeight and ClearUserRowHeights methods to handle this. _________________ Infralution Support |
|
Back to top |
|
|
WaqasK
Joined: 21 Oct 2006 Posts: 32
|
Posted: Fri Dec 05, 2008 4:01 am Post subject: |
|
|
Infralution wrote: | No there isn't an event for this. You'd need to override the the VirtualTree.SetUserRowHeight and ClearUserRowHeights methods to handle this. |
Hi,
Thanks for the info. I've trid implementing the SetUserRowHeight method but I can't seem to get it to work. In the below example I want to set the hieght of all rows in the table to 50:
Code: |
Private Sub setRowHeights(ByRef vt As VirtualTree)
Dim vtRow As Infralution.Controls.VirtualTree.Row
Dim rowList As IList = Nothing
For i As Integer = 0 To vt.RootRow.NumChildren - 1
vtRow = vt.RootRow.ChildRowByIndex(i)
setUserRowHeight(vtRow, 50)
Next
End Sub
Public Overridable Sub setUserRowHeight(ByVal row As Row, ByVal height As Integer)
'MsgBox(row.RowIndex.ToString + " " + height.ToString)
End Sub |
What am I doing wrong?
Also, is there a way to get the heights of all rows in a tree?
Thanks,
Waqas |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Fri Dec 05, 2008 9:40 pm Post subject: |
|
|
You need to inherit a new class from Virtual Tree and then override the SetUserRowHeight method (using the overrides keyword) in the derived class. This method is only used to set row heights that are changed by the user. If you want to change all the heights of all rows then you would normally set VirtualTree.RowHeight. _________________ Infralution Support |
|
Back to top |
|
|
WaqasK
Joined: 21 Oct 2006 Posts: 32
|
Posted: Sat Dec 06, 2008 12:14 pm Post subject: |
|
|
Ok, here's what I've got now:
Code: | Public Class rowHeightTree
Inherits Infralution.Controls.VirtualTree.VirtualTree
Public Overrides Sub setUserRowHeight(ByVal row As Infralution.Controls.VirtualTree.Row, ByVal height As Integer)
MsgBox(row.RowIndex.ToString + " " + height.ToString)
End Sub
Public Overrides Function getUserRowHeight(ByVal row As Infralution.Controls.VirtualTree.Row) As Integer
End Function
End Class
|
in my main class:
Code: |
Private Sub setRowHeights(ByRef vt As VirtualTree)
Dim vtRow As Infralution.Controls.VirtualTree.Row
Dim rowList As IList = Nothing
For i As Integer = 0 To vt.RootRow.NumChildren - 1
vtRow = vt.RootRow.ChildRowByIndex(i)
Dim mList As New rowHeightTree
'MsgBox(vtRow.Item)
mList.setUserRowHeight(vtRow, 25)
Next
End Sub |
But this still does not work for me.... |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Sun Dec 07, 2008 1:00 am Post subject: |
|
|
Because you have overridden the methods if you don't call the base class method then the won't do anything. You should not override the GetUserRowHeight method. eg
Code: | Public Class rowHeightTree
Inherits Infralution.Controls.VirtualTree.VirtualTree
Public Overrides Sub SetUserRowHeight(ByVal row As Row, ByVal height As Integer)
MsgBox(row.RowIndex.ToString + " " + height.ToString)
MyBase.SetUserRowHeight(row, height)
End Sub
End Class |
You should then find that your derived method is called when the user interactively resizes a row. _________________ Infralution Support |
|
Back to top |
|
|
WaqasK
Joined: 21 Oct 2006 Posts: 32
|
Posted: Mon Dec 08, 2008 3:03 pm Post subject: |
|
|
Hi,
Thanks for lookng at this again. But I'm afraid it's still not working.
Just to be clear, my aim is to save the heights of each virtual tree row to a database when the virtual tree is closed. When it is reloaded I will get the saved height values from the DB and automatically assign them to the Virtual tree rows. I intended to do this using the SetUserRowHeight method. But is this even possible? |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Mon Dec 08, 2008 7:55 pm Post subject: |
|
|
Yes this is possible. If you email a sample project demonstrating what you are doing to support@infralution.com we will take a look at it. _________________ Infralution Support |
|
Back to top |
|
|
|