|
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
|
|
|
|
|
Bill Gates dies and is at the pearly gates talking with Saint Peter. Saint Peter says, "Bill, you've done some wonderful things in your life and have earned the right to choose where you'll spend the rest of eternity. You can choose between Heaven or Hell, but choose wisely."
Bill looks over Saint Peter's shoulder between the pearly gates and sees nothing but a lush green meadow. Deciding to heed Saint Peter's words, Bill asks if he could take a look at Hell. Saint Peter agrees and sends Bill to Hell.
The Devil greets Bill at the gates of Hell and he is immediately taken aback. Much to his surprise, there's one heck of a party going on. People are dancing, the alcohol is flowing, music is non-stop and everyone is having a blast.
Bill returns to Heaven to again discuss his decision with Saint Peter. He again looks over Saint Peter's shoulder and sees only a lush green meadow. Bill says to Saint Peter, "I've put a lot of thought into this decision and it may sound foolish, but I'd like to spend the rest of eternity in Hell." Saint Peter fulfills Bill's request and returns him to Hell.
When Bill gets back to Hell there's been a big change. People are writhing in agony, flames are burning, moans of pain and despair are everywhere. Bill, being quite shocked at the sight asks the Devil, "What happened?? I was just down here a little while ago and everyone was having a great time!"
The Devil says, "Oh that... That was just the demo!"
Error: Cannot find keyboard, press F1 to continue!
|
|
|
|
|
hello i want to access remote desktop using wmi in c#. but i have study that from wmi we can access the propties of the remote dektop aceess but what procedure will get the remote desktop.
my purpose of aceess to get desktop and troubleshoot system remotly.
amar
|
|
|
|
|
Hello,
Recently I have been involved in a debate as to what environment (C# or C++) is better for developing a highly scalable Completion Ports based server capable of handling thousands of simultaneous connections (namely, its network layer). The issue is still open. I would really like to hear opinion of the community with all the pros and cons (within boundaries of the task, i.e. - network layer) of both environments. All opinions are very much appreciated.
Thanks in advance. Dennis.
|
|
|
|
|
|
I have a BindingList holding my business objects of type User.
Inside User I have a property called Address of type Address. The Address class has properties for City, and StreetAddress.
If I bind a DataGridView to my BindingList of Users, how do I get a column to display the StreetAddress stored in the property Address?
I already tried a custom column with the DataPropertyName set to Address.StreetAddress but with no luck.
I've been Google searching this for hours and have found no articles making reference to this issue. Am I the only one confused by this?
-Mike
|
|
|
|
|
good day everyone,
i believe i have a stoooopid problem , here it is: i create an empty project, i connect to oracle using the Add new Data Source wizard, fine! when im done, i drag and drop the fields from the tree window but i cant update anything against the data base!! what's more, is im getting the very same stooopid problem when connection to access!!
this.pROFILETableAdapter.Update(this.dataSet1.PROFILE); //ORA-01745: invalid host/bind variable name
please help,
Muammar.
All generalizations are wrong, including this one!
|
|
|
|
|
Please tell me how can we make multiple SDI application to show one child window .... that can not maximized or minized.
|
|
|
|
|
hi hasan, first you need to set the container form "the parent" property mdi container to true from the form properties, then when poping up another form to be the child, do this
yourChildForm kid = new yourChildForm();
yourChildForm.MdiParent=this; //when invoking from the parent form
yourChildForm.Show();
for the child form, set the minimize/maximize options from the properties window to false;
regards,
Muammar.
All generalizations are wrong, including this one!
|
|
|
|
|
The Classes supplied by the .NET Framework cann't insert a breakpoint,Such as the ArrayList Class.When I want to know how this Class implements,but the MSDN only gives some information about the properites,functions signature,The details are not showed to me.Is there any way to see these classes details.For Example:How Can I debug into the Classes given by .NET Framework?
|
|
|
|