I want to be able to allow the user to move columns around then automatically save the layout, next time they open the program, automatically load the saved layout.
I have looked through the forums for some hint as to how to do it. does anyone have any sample code on how to save and load grid layouts?
vb.net would be preferred, but C#, I cna convert.
Thanks
It's no big deal to do it on every column change. But if you are concerned about efficiency, what I would do is add a method to the usercontrol to save the grid layout, and then call that from the form that the usercontrol is on. :)
Even if you don't have a form_closed event, you must have a form somehow. Here is what I did:
In the Layout event, try to save the form in a property (ContainerForm):
{
}
in the property, listen to the form_closed event:
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
get
set
m_ContainerForm.FormClosed -= new FormClosedEventHandler(m_ContainerForm_FormClosed);
if (m_ContainerForm != null)
in the event handler save the layout:
SaveLayout();
i would, except it is part of a custom control... And other then the dispose event. I dont have a form.close
Hi,
Why not just save the layout once when the form closes, like in the Form_Closed event? It's a bit inefficient to keep saving and re-saving the layout every time a column is moved. :)
That is the one I am using...
AfterColPosChanged.
In that event, depending upon which tab is active, which determines how the grid is setup. I use the following code.
' Following code saves the ultraGrid1's layout to a file in xml format.
Dim fs As System.IO.FileStream = Nothing
If _currentGrid.ToString = "1" Then
XML_LAYOUT_FILE_PATH += ".\SCLIntraRecipientGrid.xml"
Else
XML_LAYOUT_FILE_PATH += ".\SCLIntraLocationGrid.xml"
Try
' Open a new file to save the layout to.
Catch exc As Exception
Return
End Try