By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,881 Members | 1,129 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,881 IT Pros & Developers. It's quick & easy.


P: n/a
Synopsis: DataGridViewColumn reorder does not update display, but a
repopulation of underlying dataset does...

I must be missing something obvious. I have a scenario where the
underlying XML data schema may change and need to populate a datagrid
with the result. The row data will always consist of one simple string
element with multiple attributes -- the number and names of the
attributes may change. When the data is read in by the app, the
attributes of the element become the first columns of the datagridview
and the text of the element becomes the last column -- this is the
opposite of what is desired.

So, I have undertaken to re-order the data. the issue is that the first
re-order attempt does not work. if the full routine is run a second
time, it produces the correct result as far as column order...

In testing, the Invalidate and Refresh methods of the DataGridView

'****Code from inside a Button.Click handler***
dset = New DataSet()
dset.ReadXmlSchema(My.Application.CurrentDirectory +

Dim xr As XmlReader
Dim xrs As New XmlReaderSettings()
xrs.IgnoreWhitespace = True
xrs.XsdValidate = True
AddHandler xrs.ValidationEventHandler, AddressOf ValidationHandler

xrs.Schemas.Add(Nothing, New
XmlTextReader(My.Application.CurrentDirectory + "\Keywords.xsd"))
xdd = New XmlDataDocument(dset)
xr = XmlReader.Create(txtKeywordsFile.Text, xrs)

dgrdvwKeywords.DataSource = dset
dgrdvwKeywords.DataMember = "keyword"

'reorder columns so that keyword is first
For Each col As DataGridViewColumn In dgrdvwKeywords.Columns
If (col.Name = "keyword_text") Then
col.Name = "keyword"
col.DisplayIndex = 0
col.DisplayIndex += 1
End If

nemo me impune lacessit

*** Sent via Developersdex ***
Nov 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.