|
Thank you very much!But when I move the Form2,the line disappear.
|
|
|
|
|
That is because the form gets damaged. You have to redraw the line each time the form gets damaged.
|
|
|
|
|
You're confusing the concept of "drawing a line" with "creating a static line control". Drawing is done in response to a paint message by Windows. The call to form.Dialog() causes the instance of Form2 to repaint itself. Since the form doesn't contain a red panel with a red line, it isn't shown when the form is displayed.
/ravi
|
|
|
|
|
Thank you very much!But could you conduct me to solve the problem,"creating a static line control".
|
|
|
|
|
After making an executable program in Visual .NET C#.
I click to the icon of the program and the windows is appearing.
And I click second time, the another copy of the program is appearing.
I'd like to avoid from opening copy of the program even after clicking to the
icon of the program.
How to avoid from copy of windows.
|
|
|
|
|
Hi,
just use the search[^] function.
Robert
|
|
|
|
|
Search the forums and articles for "single instance", these are the right keywords you are looking for.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
u would have to use MUTEX variable to maintainn single instance
|
|
|
|
|
Hi,
I want to know how to create my own public & private key pairs, is it correct to use the following codes? And what are valid parameters P, Q, Modulus, any sample codes?
----------------------------------------------------------------------
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(1024);
System.Security.Cryptography.RSAParameters parameters = new System.Security.Cryptography.RSAParameters();
parameters.P=???;
parameters.Modulus=???;
.............
...............
rsa.ImportParameters(parameters)
----------------------------------------------------------------------
Thanks & best regards,
Ed.
|
|
|
|
|
I have a Problem To add dynamic control to the Form
i save the controls in array list but when i add the control to Form The added ( the count property of this.Controls updated) But they areen' add to Form ( can't see any thing)
my code is :
int count = 1;
foreach (MyControl _control in ArrayList)
{
this.Controls.Add(_control);
_control.Location = new Point(count * 20, count *20);
count++;
}
What's The Problem
?
With Thanks
MHF
|
|
|
|
|
Hi,
I would first check if the Size and Visible properties of the added controls are correct. Other than that the code principally looks fine.
Robert
|
|
|
|
|
I think Problem is that i read the control's data from ArrayList
because when i use the 'new' keyword that's work
if is it true ?
With Thanks
MHF
|
|
|
|
|
The following is a question i faced in an interview...They asked me the ouput of the following code snippet
using System;<br />
<br />
namespace CsharpTestQ<br />
{<br />
public class ClassA<br />
{<br />
public virtual void printStr()<br />
{<br />
Console.Write("A");<br />
}<br />
}<br />
<br />
public class ClassB:ClassA<br />
{<br />
public override void printStr()<br />
{<br />
Console.Write("B");<br />
}<br />
}<br />
<br />
public class ClassC:ClassB<br />
{<br />
public virtual void printStr()<br />
{<br />
Console.Write("C");<br />
}<br />
}<br />
<br />
public class ClassD:ClassC<br />
{<br />
public override void printStr()<br />
{<br />
Console.Write("D");<br />
}<br />
}<br />
<br />
class Class1<br />
{<br />
<br />
[STAThread]<br />
static void Main(string[] args)<br />
{<br />
<br />
ClassD d=new ClassD();<br />
ClassA a=d;<br />
ClassB b=d;<br />
ClassC c=d;<br />
<br />
a.printStr();<br />
b.printStr();<br />
c.printStr();<br />
d.printStr();<br />
<br />
Console.ReadLine();<br />
<br />
}<br />
}<br />
}
I thought it would be "DDDD" since the object is the same (d) and the vtable in "d" points to the function printStr in ClassD. But when i tried it, the output is "BBDD". Can any one explain what is happening here?
|
|
|
|
|
Hi,
class C shadows the printStr function and thus every call on C or D will call the new function. When compiling this I would think the C# compiler should give out a warning, because normally a explicit new should be put onto the shadowing method declaration.
Robert
|
|
|
|
|
Hi,
Thanks for the reply.
Does this mean that when an object of ClassD is created there's actually two implementation of "printStr" (old and new)within the object? how does the runtime determine which function to call?
Jithu
|
|
|
|
|
Hi,
the implementation of the function is not hold within the object, but yes the class has two different implementations. Which one is called is already determined at compile time. There is another fancy behavior like this when working with explicit interface implementations:
public interface ITest {
public string GetString();
}
public class TestClass : ITest {
public string GetString() {
return "A";
}
string ITest.GetString() {
return "B";
}
}
Now guess what the output of the following code is...
TestClass testClass = new TestClass();
ITest testInterface = testClass;
Console.Write(testClass.GetString());
Console.Write(testInterface .GetString());
The output is AB .
Robert
|
|
|
|
|
Hi,
Thanks!!!
Basic Inheritance in itself is difficult...and these fancy feautures aren't making things easier...
When do we apply these concepts of Shadowing and explicit interface in our code?
Jithu
|
|
|
|
|
Hi,
explicit interface implementations are nice for interfaces like IClonable . The Clone method of IClonable always returns an object (I know there is also a generic version but thats another story). But in most case you also want a typesafe version. With explicit interface implementation you can implement ICloneable while still supplying a typesafe Clone method:
public class Test : IClonable {
public Test Clone() {
}
IClonable.Clone() {
return this.Clone();
}
}
So if you call clone on a variable typed to Test you will also get a Test instance while you'll get an object when working on the interface.
Shadowing can also be useful. Lets assume you have an interface which has a Name property. Lets also assume you have some user control which should implement this interface. Now you have the problem that the Name property from the user control (inherited from Control ) does have a complete different meaning than the Name property of your interface. You could even break the designer when changing the normal Name property. Thus you could either use explicit interface implementation (see above) or use shadowing. When using the new keyword on your Name property it will look like a normal property and can be used as an implicit interface implementation. But everyone using the Name property from a Control typed variable (like the designer does) still gets the same behaviour as before.
Robert
|
|
|
|
|
Thanks...The examples were gr8...Now i have got some idea where to apply the concepts...
|
|
|
|
|
Great, this is a classic concept.
ClassD d=new ClassD();
ClassA a=d;
ClassB b=d;
ClassC c=d;
let me explain the above four lines..
ClassD d=new ClassD(); // Straight fwd..
ClassA a=d; // here we get a reference of ClassD's object in typeof(ClassA)
note that ClassD inherits A,B,C.
now when u call a.get(), the call is forwarded to B.GetString and stops in here, cos the method in c is totally a new one,.
ClassB b=d; here B.GetString() excecutes.
ClassC c=d; -- C.getString is called and it forwards the call to D.getstring.
|
|
|
|
|
... i have a problem communicating on the serial port(COM1 or COM2).Here's the code:
private void Form1_Load(object sender, EventArgs e)
{
if (!serialPort1.IsOpen)
serialPort1.Open();
serialPort1.DtrEnable = true;
}
private void serialPort1_DataReceived(object sender,
System.IO.Ports.SerialDataReceivedEventArgs e
{
MessageBox.Show(serialPort1.ReadExisting()+"geo");
textBox1.Invoke(new EventHandler(delegate { textBox1.Text +=
serialPort1.ReadExisting();}));
}
...if I connect pin2 with pin3 of the serial port(RX,TX),and i try to transmit something on the serial port, it works(the serialPort1_DataReceived event is raised and i get the data i have sent)...but when i connect a sensor(for a remote control) on the serial port and a push a button on the remote nothing happens. the sensor works because i have tested it with a special program named GIRDER(when i push a button on the remote it shows the code of the button on the screen). If someone could help i would appreciate it.
|
|
|
|
|
You need to set up your serial port so that all serial parameters match the parameters of the sensor that you are trying to communicate with.
This includes baud rate, start bits, stop bits, parity, etc. If you don't have a datasheet that gives you these parameters, you will have to do some experimentation.
I would suggest that you get a simple terminal program so that you can easily verify operation. I recommend Br@y terminal. Only because it is very lightweight, and it lets you set all parameters from the main screen.
Once you know all the serial parameters, it should be easy to get your program to work. There are many good example of serial software on CP that will help you.
Also, once you get Br@y terminal to work with your sensor, you can test your code with Br@y.
-squeaker-
|
|
|
|
|
I want to backup SQL SERVER 2000 database and zip it using .NET 1.1 . The application must be connect remote system by using windows authentification is there any website to produce the code in .NET 1.1 in any language(c#.net or vb.net)
this is haneef
|
|
|
|
|
I have problem vith vs2003 editor when press F5 for output c# with asp webapplication it returns dialog box like Error while trying to run a project: Unable to start debugging on webserver.you do not have permissions to debug the server. verify you are a member of 'dbugger users' groups on the server
haneef.skk@gmail.com
|
|
|
|
|
Hi,
I have a TreeView Application.In that for a single node i need to get 4 images.That is in a menu i had an option.If that is set then I need to set two images while selecting and deselcting.If that is not set then i need to get two imaegs one for setting and the other is deselect.Now I am able to set 3 images.Can I have any Idea About this
|
|
|
|