-- i tried this and it works 4 me. I'm not sue if this is what you were
trying to acheive ?
Public Class Form1
Inherits System.Windows.Forms.Form
Dim ds As New DataSet("MySet")
Dim myTab As DataTable
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents dg As System.Windows.Forms.DataGrid
Friend WithEvents ClearTab As System.Windows.Forms.Button
Friend WithEvents SaveXML As System.Windows.Forms.Button
Friend WithEvents ReadXML As System.Windows.Forms.Button
Friend WithEvents AddName As System.Windows.Forms.Button
Friend WithEvents aName As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.dg = New System.Windows.Forms.DataGrid
Me.ClearTab = New System.Windows.Forms.Button
Me.SaveXML = New System.Windows.Forms.Button
Me.ReadXML = New System.Windows.Forms.Button
Me.AddName = New System.Windows.Forms.Button
Me.aName = New System.Windows.Forms.TextBox
CType(Me.dg, System.ComponentModel.ISupportInitialize).BeginIni t()
Me.SuspendLayout()
'
'dg
'
Me.dg.DataMember = ""
Me.dg.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.dg.Location = New System.Drawing.Point(144, 128)
Me.dg.Name = "dg"
Me.dg.Size = New System.Drawing.Size(208, 128)
Me.dg.TabIndex = 0
'
'ClearTab
'
Me.ClearTab.Location = New System.Drawing.Point(24, 48)
Me.ClearTab.Name = "ClearTab"
Me.ClearTab.TabIndex = 1
Me.ClearTab.Text = "Clear"
'
'SaveXML
'
Me.SaveXML.Location = New System.Drawing.Point(184, 48)
Me.SaveXML.Name = "SaveXML"
Me.SaveXML.TabIndex = 2
Me.SaveXML.Text = "SaveXML"
'
'ReadXML
'
Me.ReadXML.Location = New System.Drawing.Point(344, 48)
Me.ReadXML.Name = "ReadXML"
Me.ReadXML.TabIndex = 3
Me.ReadXML.Text = "Read XML"
'
'AddName
'
Me.AddName.Location = New System.Drawing.Point(24, 96)
Me.AddName.Name = "AddName"
Me.AddName.TabIndex = 4
Me.AddName.Text = "Add Name"
'
'aName
'
Me.aName.Location = New System.Drawing.Point(112, 96)
Me.aName.Name = "aName"
Me.aName.TabIndex = 5
Me.aName.Text = ""
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(480, 273)
Me.Controls.Add(Me.aName)
Me.Controls.Add(Me.AddName)
Me.Controls.Add(Me.ReadXML)
Me.Controls.Add(Me.SaveXML)
Me.Controls.Add(Me.ClearTab)
Me.Controls.Add(Me.dg)
Me.Name = "Form1"
Me.Text = "Form1"
CType(Me.dg, System.ComponentModel.ISupportInitialize).EndInit( )
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim dr As DataRow
ds.Tables.Add("myTable")
myTab = ds.Tables("myTable")
myTab.Columns.Add("FirstName")
dr = myTab.NewRow
dr("FirstName") = "John"
myTab.Rows.Add(dr)
dg.DataSource = ds.Tables("myTable")
End Sub
Private Sub SaveXML_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles SaveXML.Click
ds.WriteXml("C:\myxml.txt")
End Sub
Private Sub ReadXML_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ReadXML.Click
ds.Clear()
ds.ReadXml("c:\myxml.txt")
End Sub
Private Sub AddName_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles AddName.Click
Dim dr As DataRow
dr = myTab.NewRow
dr("FirstName") = aName.Text
myTab.Rows.Add(dr)
End Sub
Private Sub ClearTab_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ClearTab.Click
ds.Clear()
End Sub
End Class
"Juan Romero" <ju******@optonline.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hey guys, please HELP
I am going nuts with the datagrid control.
I cannot get the damn control to refresh. I am using soap to get
information from a web service. I have an XML writer output the file to a folder, and
then I read it back into the dataset using the dataset1.readxml. Up to
this point, everything works wonderfully. The query executes, the dataset gets
populated, and I get the results displayed in the datagrid.
The problem:
When I run another query, everything goes as before expect that the
datagrid columns WON'T REFRESH. I can see the data changes, but the columns remain,
and since the columns don't match any other column in the new set,
everything is (null).
How do I REFRESH the grid columns?.... I mean, I have tried everything, I
have called the dataset.clear() method, I have called the
dataset.table.clear() method, I have unbound the grid from the datasource
and rebound again, deleted all tables, etc etc etc. I just can't get rid
of the damn columns.
Please help, it's been a long weekend and it is getting frustrating.....
Thank you in advance.
Regards.