neil.interactit wrote:No, I struck out - I thought I was onto something but it has stumped me! Any chance of a sample demo?
A working sample will have to wait a while - but I can point you in the direction that I would try.
The grid has a method for the sheet (i.e.: Grid.ActiveSheet) named GenerateXMLDefinition - it returns a string representation of the XML document of the grid columns. Load that into a System.Xml.XmlDocument, parse it, set the value for the node you want, the call the ApplyXMLDefinition method of the sheet passing the XmlDocument as a string value.
1. Get the grid XML as a string, make a XmlDocument from it:
- Code: Select all
Dim XMLDefinition As String = MyGrid.ActiveSheet.GenerateXMLDefinition()
XMLDocument = New System.Xml.XmlDocument
XMLDocument.LoadXml(XMLDefinition)
2. Find your node of interest and set the value (incomplete code here - you'll need to work out how to efficiently find the node you want and set the value):
- Code: Select all
xmlElement As System.Xml.XmlElement = XMLDocument.SelectSingleNode("JiwaGridDefinition/ListOfColumns")
If Not (xmlElement Is Nothing) Then
For Each columnXMLElement As System.Xml.XmlElement In xmlElement.ChildNodes
' ... work out which node you want, change the value here columnXMLElement as a Name property - "Key" is the column key, "Caption" is the display value
If Found Then
' Generate a string representation of the XML document, and exit processing
XMLString = XMLDocument.OuterXml
Exit For
End If
Next
End If
3. Apply the new XML:
- Code: Select all
MyGrid.ActiveSheet.ApplyXMLDefinition(XMLString)
Mike