|
Run your Model dialog in a saperate thread instead of running it from main application. YOu have to start a new thread to show your model dialog box.
Regards,
Amit Kumar
HDISM, PGDCA, MCP, MCAD, MCSD
amit_chikara2002@hotmail.com
|
|
|
|
|
Hi,
use forms TopMost property and set it to true.
hope this works.
Nitin...
|
|
|
|
|
Hi All,
Im fairly new to C#.
When I load a image as background to my form, and I place some controls on top of the form; the loading is very slow. painfully slow.
How do I achieve what i need? I want to have a background image, for the form, but have some controls on the form that load faster, and do not take much time to refresh....???
B
|
|
|
|
|
Hi,
If you set the background image at desing time it the painting of your form can take a little longer.Try using this code:
<br />
static Image image = Image.FromFile(Application.StartupPath+"\\image.jpg");<br />
private void frmMain_Paint(object sender, System.Windows.Forms.PaintEventArgs e)<br />
{<br />
e.Graphics.DrawImage(image, 0, 0, new Rectangle(0, 0, image.Width, image.Height), GraphicsUnit.Pixel);<br />
this.SuspendLayout();<br />
for (int i = 0 ; i < this.Controls.Count ; i++)<br />
this.Controls[i].Update();<br />
this.ResumeLayout(true);<br />
}<br />
Do your best to be the best
|
|
|
|
|
Hi,
I usually put all my codes in one .cs file. But im now trying a bit organized programming.
I made a method in another file, an xml writer file. And i want to send commands to it from my form.cs file.
So how can i access a method which is in for example alfa.cs file from beta.cs file?
Both files are in the same project.
Thanks in advance!
|
|
|
|
|
Hi,
The only thing that you need to do for using a class/method from another file from the same project is to use the NameSpace inside which is the method. Nothing else.
Hope it helps
Do your best to be the best
|
|
|
|
|
Hi,
They all have the same namespace.
|
|
|
|
|
If a method is static, then you can call it from anywhere in your project. If it's not static, you need an instance of the class to call the methods on.
Class C1
{
private int n = 0;
private static int s = 0;
public int Int { get { return n; } }
public int IntS { get { return s; } }
public void Add(int i) { n += i; }
public static AddS(int i) { s+=i; }
}
Class C2
{
public DoStuff()
{
C1.AddS(10);
Console.WriteLine(C1.IntS.ToString()); // 10
C1 c1 = new C1();
c1.Add(5);
Console.WriteLine(c1.Int.ToString()); // 5
C1 c2 = new C1();
c2.Add(52);
// c2.Int now = 52, c1.Int still = 5, C1.IntS still = 10
C1.AddS(10);
Console.WriteLine(C1.IntS.ToString()); // 20
c1.Add(12);
Console.WriteLine(c1.Int.ToString()); // 17
Console.WriteLine(c2.Int.ToString()); // 52
}
}
The most common mistake I've seen is for people to have one instance of a class, to be in another class where they don't currently have access to that instance, so they create a new instance ( often of a form ) and try to change variables on that. this won't ever change variables on any instance bar the new one, unless they are static.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi,
Nothing in my project is static.
The method is a void one, its not returning anything (as it should).
This:
C1 c2 = new C1();
Helped!
Thank you very much!
|
|
|
|
|
Yustme wrote: Nothing in my project is static.
OK, then you need to keep a specific instance of the class you want to call, so you can work with it. If the method you're calling doesn't rely on any member variables, then it should be static.
Yustme wrote: The method is a void one, its not returning anything (as it should).
OK, that makes no sense. If it's got void, then it doesn't return anything. I think it's time you posted some code.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi,
I know it doenst return anything when its void, but it was more like extra info to your example where you showed me 2 methods that returned something.
This is my method:
public void WritingToXMLDoc(string elementString, string writeToXMLDoc)
{
this.writer.WriteElementString(elementString, writeToXMLDoc);
this.writer.WriteEndElement();
if (this.writer != null)
this.writer.Close();
}
|
|
|
|
|
Dude, that's some strange code. You check if writer is null, after using it twice, and if it's not, you call close on it. What does close do ? Does it stop WriteElementString from working later ? If this is the object I think it is, WriteEndElement is paired with WriteStartElement, so you're using it wrong.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi,
There is actually more code.
Complete class:
class XMLWriter
{
XmlWriterSettings settings = new XmlWriterSettings();
DateTime dateTimeNow = DateTime.Now;
XmlWriter writer = null;
public XMLWriter()
{
this.settings.Indent = true;
this.settings.IndentChars = "\t";
this.settings.OmitXmlDeclaration = true;
this.settings.NewLineOnAttributes = true;
this.settings.Encoding = Encoding.Default;
this.settings.ConformanceLevel = ConformanceLevel.Fragment;
this.writer = XmlWriter.Create("Testing.xml", settings);
this.writer.WriteStartElement("Information");
this.writer.WriteElementString("DateOfBuilding", dateTimeNow.ToShortDateString());
this.writer.WriteElementString("TimeOfBuilding", dateTimeNow.ToLongTimeString());
}
public void WritingToXMLDoc(string elementString, string writeToXMLDoc)
{
this.writer.WriteElementString(elementString, writeToXMLDoc);
this.writer.WriteEndElement();
this.writer.Flush();
if (this.writer != null)
this.writer.Close();
}
}
writer.Close(); is to stop writing and used for disposal.
|
|
|
|
|
If both your classes are in the same namespace, simply create an instance of your class and make a call to the method
...
XMLWriter myObject = new XMLWriter();
myObject.WritingToXMLDoc("elementString", "writeToXMLDoc");
...
I'm not sure if im on the right path here but i hope it helps
|
|
|
|
|
Hi,
Thats exactly what i have
|
|
|
|
|
Yustme wrote: DateTime dateTimeNow = DateTime.Now;
Why ?
Yustme wrote: writer.Close(); is to stop writing and used for disposal.
But that reads as if the method can only be called once - why ?
What are you expecting and what are you getting ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi,
To write the date and time in the xml file too.
What do you suggets instead of using Close()?
Havent tested it all yet, but it writes the start and end element and the time and date.
|
|
|
|
|
Yustme wrote: To write the date and time in the xml file too.
But it's more than redundant, it will continue to point to the moment the file was created, which is not what Now means. And, if you only use it in one method, why is it even a member, assuming you had to create it at all ? Just use DateTime.Now.
Yustme wrote: What do you suggets instead of using Close()?
If you need to close the file, expose a method to do this, otherwise calling your other method once will close the file, but not make this clear.
Yustme wrote: Havent tested it all yet
OK, then at what point did you have a problem with what it's doing ? Or did I misunderstand you ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi,
Not having any problems atm.
|
|
|
|
|
Hi
i have to access data from a file located on a remote pc on the network. Can anybody suggest me which method to use, either asynchronous sockets or remotig. and what will be the pros and cons of using remoting or asynchronous sockets.
sAqIb
|
|
|
|
|
Hi,
My reply regards sockets. They could help you but to use sockets you have to create a server and a client application. This could be a problem sometimes. I've worked a lot with sockets and they suited well in my applications. I don't know much about remoting but sockets require a server which listens for a connection and that could pe a con sometimes
Do your best to be the best
|
|
|
|
|
Can you not use network file-sharing to achieve this?
Regards,
Rob Philpott.
|
|
|
|
|
Hi,
I have DataTable that is binded to a DataGridView. How to I retrieve the values in the columns/rows dynamically? I want to retrieve the string representation of each cell. Clearification: When user have finished entering data in the datagridview he/she hits the save button every data in each cell is saved into a objects fields.
Thanx in advance
Regards
/Christoffer
|
|
|
|
|
Hi all,
I need to covert a video file to a .flv file,
How do i do that?
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
import the video in Macromedia Flash. flv is a Flash Video.
regards,
g00fy
|
|
|
|