Click here to Skip to main content
15,881,757 members
Home / Discussions / C#
   

C#

 
AnswerRe: Unique hardware id Pin
Divyang Mithaiwala3-Apr-06 19:52
Divyang Mithaiwala3-Apr-06 19:52 
GeneralRe: Unique hardware id Pin
Kasic Slobodan4-Apr-06 10:13
Kasic Slobodan4-Apr-06 10:13 
Questionreporting via exxel or microsoft word ?! Pin
mrkeivan3-Apr-06 8:46
mrkeivan3-Apr-06 8:46 
AnswerRe: reporting via exxel or microsoft word ?! Pin
Ed.Poore3-Apr-06 9:04
Ed.Poore3-Apr-06 9:04 
GeneralRe: reporting via exxel or microsoft word ?! Pin
mrkeivan3-Apr-06 12:55
mrkeivan3-Apr-06 12:55 
GeneralRe: reporting via exxel or microsoft word ?! Pin
Ed.Poore3-Apr-06 20:34
Ed.Poore3-Apr-06 20:34 
GeneralRe: reporting via exxel or microsoft word ?! Pin
mrkeivan4-Apr-06 5:53
mrkeivan4-Apr-06 5:53 
QuestionProgrammatically adding TabPage Contents into DataGrid from XML File Pin
AnneThorne3-Apr-06 8:41
AnneThorne3-Apr-06 8:41 
Hi,

We are creating a C# Windows application using VS 2005.

It reads in an xml file and creates tab pages that each
have a datagrid that holds the specific information
for that tab's node.

We have been able to programmatically give the tab.text
(the label on the tabs), but when we try to add the
specific data for each tab into a datagrid on the
tab's page, all of the data gets added instead of the
data for just that node.

Perhaps we need to clear the grid first???

Any help would be appreciated.

Thank you in advance,
Anne




Here is a portion of the xml file we are using.
<?xml version="1.0" encoding="utf-8"?>
<inspection>
    <inspforms>
        <inspform>
            <name>general</name>
            <sections>
                <section>
                    <tab>Heading</tab>
                    <label>
                        <name>id</name>
                        <type>text</type>
                        <value>
                            <single>200621</single>
                         </value>
                    </label>
                    <label>
                        <name>request
                        </name>
                        <type>text
                        </type>
                        <value>
                            <single>30
                            </single>
                            <choices>
                                <choice>
                                </choice>
                            </choices>
                        </value>
                    </label>
 
                </section>
            </sections>
        </inspform>
        <inspform>
            <name>Risk</name>
            <sections>
                <section>
                    <tab>Operations</tab>
                    <label>
                        <name>Business Type</name>
                        <type>radio</type>
                        <value>
                            <choices>
                                <choice>
                                    <choicename>Corporation</choicename>
                                    <choicevalue>
                                    </choicevalue>
                                </choice>
                                <choice>
                                    <choicename>LLC</choicename>
                                    <choicevalue>
                                    </choicevalue>
                                </choice>
                                <choice>
                                    <choicename> Partnership</choicename>
                                    <choicevalue>
                                    </choicevalue>
                                </choice>
                                <choice>
                                    <choicename>Sole Proprietor</choicename>
                                    <choicevalue>
                                    </choicevalue>
                                </choice>
                            </choices>
                        </value>
                    </label>
                    <label>
                        <name>Years in Business</name>
                        <type>text</type>
                        <value>
                            <single>
                            </single>
                        </value>
                    </label>
                 </section>
            </sections>
        </inspform>
    </inspforms>
</inspection>



Here is the pertinent code:
//frmMain.cs
<br />
using System;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Windows.Forms;<br />
<br />
using ABC.Components;<br />
using ABC.Globals;<br />
<br />
namespace ABC.Forms<br />
{<br />
	public class frmMain : System.Windows.Forms.Form<br />
	{<br />
		public  const string Path = @"C:\ABCXmls\abcBase.xml";<br />
		public  ArrayList ArrayListTabs;<br />
<br />
		private ABC.Components.abcTabArea abcTabArea1;<br />
<br />
		private System.ComponentModel.Container components = null;<br />
<br />
		public frmMain()<br />
		{<br />
<br />
			XmlHelper.OpenFile(Path);<br />
			ArrayListTabs = new ArrayList();<br />
			ArrayListTabs = XmlHelper.GetArrayList("tab");<br />
			InitializeComponent();<br />
		}<br />
		#region InitializeComponent()<br />
<br />
		private void InitializeComponent()<br />
		{<br />
			...<br />
<br />
		}<br />
		#endregion<br />
<br />
		[STAThread]<br />
		static void Main() <br />
		{<br />
			Application.Run(new frmMain());<br />
		}<br />
<br />
		private void frmMain_Load(object sender, EventArgs e)<br />
		{<br />
			this.abcTabArea1.CreateTabs(this.ArrayListTabs, Path);<br />
		}<br />
<br />
		protected override void Dispose( bool disposing )<br />
		{<br />
			...<br />
		}<br />
<br />
<br />
	}<br />
	}<br />
}<br />

//xmlHelper.cs
<br />
using System;<br />
using System.Collections;<br />
using System.Data;<br />
using System.IO;<br />
using System.Xml;<br />
<br />
<br />
namespace ABC.Globals<br />
{<br />
	public class XmlHelper<br />
	{<br />
		private static XmlDocument XmlDocument1;<br />
<br />
		public static void OpenFile(string path)<br />
		{<br />
			XmlDocument1 = new XmlDocument();<br />
			XmlDocument1.PreserveWhitespace = false;<br />
			XmlDocument1.Load(path);<br />
		}<br />
		public static ArrayList GetArrayList(string elementName)<br />
		{<br />
			ArrayList arrayList1 = new ArrayList();<br />
<br />
			XmlNodeList xmlNodeList1 = XmlDocument1.GetElementsByTagName(elementName);<br />
<br />
			for (int idx = 0; idx < xmlNodeList1.Count; idx++) <br />
			{<br />
				XmlElement xmlElement1 = (XmlElement) xmlNodeList1[idx];<br />
				arrayList1.Add(xmlElement1.InnerText);<br />
			}<br />
	<br />
			return arrayList1;<br />
		}<br />
         }<br />
}<br />

//abcTabArea.cs
<br />
using System;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Windows.Forms;<br />
<br />
namespace ABC.Components<br />
{<br />
	public class abcTabArea : System.Windows.Forms.UserControl<br />
	{<br />
		internal TabControl TabControl1;<br />
		internal string Path = "";<br />
<br />
<br />
		private System.ComponentModel.Container components = null;<br />
<br />
		public jmpBottom()<br />
		{<br />
			abcTabArea();<br />
		}<br />
<br />
		#region InitializeComponent()<br />
		private void InitializeComponent()<br />
		{<br />
			...<br />
		}<br />
		#endregion<br />
<br />
		public void CreateTabs(ArrayList arrayListTabNames1, string path)<br />
		{<br />
			this.Path = path;<br />
			for (int idx = 0; idx < arrayListTabNames1.Count; idx++)<br />
			{<br />
				string tab = "";<br />
				tab = arrayListTabNames1[idx].ToString();<br />
<br />
				System.Windows.Forms.TabPage abcTabPage = new TabPage(tab);<br />
<br />
				abcPage abcPage = new abcPage(tab,this.Path,idx);<br />
<br />
				this.abcTabControl1.Controls.Add(abcTabPage);<br />
				abcTabPage.Controls.Add(abcPage);<br />
<br />
			}<br />
		}<br />
<br />
<br />
		protected override void Dispose( bool disposing )<br />
		{<br />
			...<br />
		}<br />
<br />
	}<br />
}<br />

\\abcPage.cs
<br />
using System;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Windows.Forms;<br />
using System.Xml;<br />
<br />
<br />
namespace ABC.Components<br />
{<br />
<br />
	public class abcPage : System.Windows.Forms.UserControl<br />
	{<br />
		internal string NodeName = "";<br />
		internal string Path = "";<br />
		internal int indexNum = 0;<br />
		private System.Windows.Forms.Panel panel1;<br />
		private System.Windows.Forms.DataGrid dataGrid1;<br />
		private System.ComponentModel.Container components = null;<br />
<br />
		public jmpPage(string nodeName, string path, int indexNum)<br />
		{<br />
			this.NodeName = nodeName;<br />
			this.Path = path;<br />
			this.indexNum = indexNum;<br />
			InitializeComponent();<br />
            		Populate();<br />
		}<br />
<br />
		#region InitializeComponent()<br />
<br />
		private void InitializeComponent()<br />
		{<br />
			this.panel1 = new System.Windows.Forms.Panel();<br />
			this.dataGrid1 = new System.Windows.Forms.DataGrid();<br />
			this.panel1.SuspendLayout();<br />
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();<br />
			this.SuspendLayout();<br />
			// <br />
			// panel1<br />
			// <br />
			this.panel1.Controls.Add(this.dataGrid1);<br />
			this.panel1.Location = new System.Drawing.Point(0, 0);<br />
			this.panel1.Name = "panel1";<br />
			this.panel1.Size = new System.Drawing.Size(800, 528);<br />
			this.panel1.TabIndex = 0;<br />
			// <br />
			// dataGrid1<br />
			// <br />
			this.dataGrid1.DataMember = "";<br />
			this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;<br />
			this.dataGrid1.Location = new System.Drawing.Point(0, 0);<br />
			this.dataGrid1.Name = "dataGrid1";<br />
			this.dataGrid1.Size = new System.Drawing.Size(800, 528);<br />
			this.dataGrid1.TabIndex = 0;<br />
			// <br />
			// jmpGeneral<br />
			// <br />
			this.Controls.Add(this.panel1);<br />
			this.Size = new System.Drawing.Size(800, 528);<br />
			this.panel1.ResumeLayout(false);<br />
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();<br />
			this.ResumeLayout(false);<br />
<br />
		}<br />
		#endregion<br />
<br />
		internal void Populate()<br />
		{<br />
			DataSet dataSet1 = new DataSet();<br />
			XmlDocument XmlDocument1;<br />
			XmlDocument1 = new XmlDocument();<br />
			XmlDocument1.PreserveWhitespace = false;<br />
			XmlDocument1.Load(this.Path);<br />
<br />
			XmlNodeList xmlNodeList = XmlDocument1.GetElementsByTagName("section");<br />
<br />
			XmlElement xmlElement1 = (XmlElement) xmlNodeList[this.indexNum];<br />
			dataSet1.ReadXml(this.Path);<br />
			dataGrid1.DataSource = dataSet1;<br />
			dataGrid1.DataMember = "section";<br />
			dataGrid1.CaptionText = dataGrid1.DataMember;<br />
		}<br />
<br />
		protected override void Dispose( bool disposing )<br />
		{<br />
			...<br />
		}<br />
	}<br />
}<br />

QuestionDrag and Drop Label in a Panel Pin
cbeasle13-Apr-06 7:42
cbeasle13-Apr-06 7:42 
AnswerRe: Drag and Drop Label in a Panel Pin
Robert Rohde3-Apr-06 8:10
Robert Rohde3-Apr-06 8:10 
Questionwhy is the program running so slow Pin
Agyeman3-Apr-06 6:39
Agyeman3-Apr-06 6:39 
AnswerRe: why is the program running so slow Pin
Ed.Poore3-Apr-06 7:47
Ed.Poore3-Apr-06 7:47 
GeneralRe: why is the program running so slow Pin
Agyeman3-Apr-06 8:15
Agyeman3-Apr-06 8:15 
GeneralRe: why is the program running so slow Pin
Guffa3-Apr-06 7:55
Guffa3-Apr-06 7:55 
QuestionApplication.Exit() - How do I return an exit code. Pin
Mark42623-Apr-06 6:36
Mark42623-Apr-06 6:36 
AnswerRe: Application.Exit() - How do I return an exit code. Pin
Braulio Dez3-Apr-06 6:58
Braulio Dez3-Apr-06 6:58 
GeneralRe: Application.Exit() - How do I return an exit code. Pin
Ravi Bhavnani3-Apr-06 7:08
professionalRavi Bhavnani3-Apr-06 7:08 
GeneralRe: Application.Exit() - How do I return an exit code. Pin
Ed.Poore3-Apr-06 7:49
Ed.Poore3-Apr-06 7:49 
GeneralRe: Application.Exit() - How do I return an exit code. Pin
Ravi Bhavnani3-Apr-06 9:01
professionalRavi Bhavnani3-Apr-06 9:01 
GeneralRe: Application.Exit() - How do I return an exit code. Pin
vineas3-Apr-06 7:53
vineas3-Apr-06 7:53 
GeneralRe: Application.Exit() - How do I return an exit code. Pin
Mark42623-Apr-06 8:24
Mark42623-Apr-06 8:24 
GeneralRe: Application.Exit() - How do I return an exit code. Pin
Ravi Bhavnani3-Apr-06 9:01
professionalRavi Bhavnani3-Apr-06 9:01 
GeneralRe: Application.Exit() - How do I return an exit code. Pin
Ravi Bhavnani3-Apr-06 9:02
professionalRavi Bhavnani3-Apr-06 9:02 
QuestionDetecting an already running application Pin
royk1233-Apr-06 5:44
royk1233-Apr-06 5:44 
AnswerRe: Detecting an already running application Pin
Stefan Troschuetz3-Apr-06 5:56
Stefan Troschuetz3-Apr-06 5:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.