you can use public static global variable in first forms class (For example form1) and can access that data from next class by(form1.variablename).
Never ever suggest that! It is very bad practice to do this: fro example what happens if you need two instances of form2 with different parameters? Rmember we get a lot of beginners reading this forum - we do not want them getting the idea that this is something you should do in the real world!
Either pass parameters via the second form constructor, or use events to pass / pick up the data.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
I have an xml file in the directory of the myproject.exe file of my project. as a result i m using relative path to open the xml file.
I am openig the file using the following code:
XmlTextReader xtr = new XmlTextReader("center.xml");
I have a open file dialog box in that project and i read a MSAccess file using that open file dialog box. But after reading the MSAccess file when I try to read the xml file with the same code then exception raised and shows could not find file "path of the MSAccessfile\center.xml"
So how can I get back to the directory whre the myproject.exe file located"
Further to the pevious answer, using relative paths isn't a great idea. If you know for sure where a file is then use the path. The file center.xml should probably be in the runnign directory and not the application directory. Though normally the same, they can be different. The best to use is System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
If I'd noticed what the tags were telling me when I hovered over the foreach I'd have seen this for myself. I removed the declaration of the DBList in form 2 and qualified the DBList in the foreach with the form 1 instance and it all works !!