1

I want to read Stream that i get from XtrapivotGrid of DevExpress. I can save it in the computer but what i want is to save it in one of my table in my dataset called dataset1. For now i have that code who permit to save it the directory Temp:.

Using FS As New IO.FileStream("D:\Temp\qqc.layout", IO.FileMode.Create)
     PivotGridControl1.SaveLayoutToStream(FS)
End Using

Dim read As New System.IO.FileStream("D:\Temp\qqc.layout", IO.FileMode.Open, IO.FileAccess.Read)
DataSet1.LayoutMainRapport.ReadXml(read)
DataSet1.AcceptChanges()
read.Close()

The table LayoutMainRapport have 3 columns:

  • ID(Int)
  • Name(nvarchar(50))
  • Content(xml).

The output from the stream is xml.

thanks in advance!

4

2 に答える 2

1

I believe you should convert your saved layout into string and then save this string to database (and of course you can load this layout back from the database string value):

Private Function SaveLayoutToString(ByVal dxControl As DevExpressControl) As String
    Using ms As MemoryStream = New MemoryStream()
        dxControl.SaveLayoutToStream(ms)
        Return Convert.ToBase64String(ms.ToArray())
    End Using
End Function
Private Sub RestoreLayoutFromString(ByVal dxControl As DevExpressControl, ByVal layout As String)
    If String.IsNullOrEmpty(layout) Then
        Return
    End If
    Using ms As MemoryStream = New MemoryStream(Convert.FromBase64String(layout))
        dxControl.RestoreLayoutFromStream(ms)
    End Using
End Sub

Here DevExpressControl dxControl is the DevExpress control which supports saving and loading layout (XtraPivotGrid, XtraGrid, XtraLayoutControl etc.)

于 2013-03-27T13:14:45.577 に答える
1

I simply had to save a name for the xml and after save it into my dataset.

    Dim saveDialog As SaveLayout = New SaveLayout
    If saveDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
        Dim read As New IO.MemoryStream
        PivotGridControl1.SaveLayoutToStream(read)
        read.Position = 0
        Dim lecteur As New IO.StreamReader(read)
        Dim ligne As DataRow = DataSet1.LayoutMainRapport.NewRow()

        ligne("Nom") = saveDialog.txtNom.Text
        ligne("Contenu") = lecteur.ReadToEnd()
        DataSet1.LayoutMainRapport.Rows.Add(ligne)
        LayoutMainRapportTableAdapter.Update(DataSet1)
    End If
于 2013-05-22T19:10:43.050 に答える