datagrid display when loading config file

H

hazz

With this code, the config file(listed below) opens initially into the
datagrid display with only a plus sign '+'.
On clicking that, it becomes expanded to;
-
appsettings
add

When I click on appsettings, it reverts back to '+' On clicking that,
- appsettings add is displayed
Finally, when I click on appsettings this time, the contents of the config
file is displayed.
What is going on here? How could I have the config file load into an
already expanded state?
Thanks -Greg

***************** code ******************************************
dsConfigFile = new DataSet("configfile");
dsConfigFile.ReadXml("c:\\Service.exe.config");
dataGrid1.DataSource = dsConfigFile;

****************** config file ******************************************
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="interval" value="10000" />
<add key="sDbConn" value="Data Source=xxxx;Database=xxxx;UID=xxx;Pwd=xxxx"
/>
</appSettings>
</configuration>
 
G

Guest

When you assign a DataSet to a Windows Forms DataGrid, the default behavior
is to display the + sign. If you want the grid to show one table, bind it
just to the one table of the DataSet and it will display expanded.
Peter
 
H

hazz

Thank you Peter.
I also found a simpler approach to just load the timer interval from the
config file into a textbox for editing.
XmlDocument myConfig = new XmlDocument();
myConfig.Load("c:\\Service.exe.config");
string strXPath;
XmlNode oNode;
strXPath = "configuration/appSettings/add[@key='interval']/@value";
oNode = myConfig.SelectSingleNode(strXPath);
textBox1.Text = oNode.InnerText;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top