|
Hi,
in the InitializeComponent-function set a absolute position where the form should located and add a handler for the Move-Event.
<br />
this.Location = new Point(10, 10);<br />
this.Move += new EventHandler(Form1_Move);<br />
In this function set also the absolute location. Now it's not possible to move the form, but it's not the finest solution.
Regards
Inikaa
|
|
|
|
|
use TopMost property...
<marquee>nishu
|
|
|
|
|
Support there is a table in SQL server database with primary key column which is an auto-increment numeric value.
Whenever we insert any row in the table we do not supply the value of primary key column; assuming that it will be automatically generated by the databse.
I insert the column programatically using C#. I need to know the autokey assigned to the last row that i've inserted. What is the best method to find that out.
Imtiaz
|
|
|
|
|
Your requirement is not quite clear, if you want to get the last autogenerated ID, then you can get it with @@IDENTITY.
Best Regards,
Apurva Kaushal
|
|
|
|
|
u can access the autokey of the last row inserted in the database by using the C# code for @@Identity. it is same like you use in Sql Server2000. please check for the correct syntax
sAqIb
|
|
|
|
|
I write a windows forms application. My form will be in english and another language. Form's neutral language is not english. when i try to load english resources the application can not load english resources and loads neutral(it does not throw an exception). I can see the form in English in design time by changing language property. So the resource file is not corrupted. How can i fix the problem? Thanks for the help
|
|
|
|
|
Use an overload that takes a CultureInfo object or change the current UI culture (Thread.CurrentThread.CurrentUICulture ) before loading resources.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi
Am a newbie to Remoting.SO tried to run an appln(Client-Server) downloaded from net.But i got error while proceeding.The link is given below(Sample 2:Two GUI Clients and a Server Application)
http://www.jot.fm/issues/issue_2004_01/column8.pdf[^][^]
I get error as "underlying connection closed" while trying to run the client2,when the coordinates of X and Y are retrieved from the server,to draw the rectangle(OnPaint Method).
Please help me how to debug applications with threads like the above one.Also please tell me a solution about why i got this error.
Thanx....
|
|
|
|
|
Hi,
I have a field in SQL Server 2005 of type money. What is the corresponding DbType? Is it Currency or Double?
Regards,
ma se
|
|
|
|
|
Double can be used to round off a value to more then 2 decimal. Currency not.
Thus, currency is the same as money as DBType.
It will be a save bet to make the DB field in your database a 'money' field, and then to save the value in it's 'current' state.
When displaying the value in your code, you can round it off, by converting it to Double.
|
|
|
|
|
Hi there,
I would like to show a modal dialog and still be able to close/minimize/maximize my main form. Is there a way to accomplish this?
I'm thankful for your help.
|
|
|
|
|
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
|
|
|
|