|
You should attempt your homework first. Your tutor should have given you all the materials you need to complete the exercise already. If you get stuck on your attempt, please post with a specific question about a specific problem you are having. Do not just post your homework questions and expect someone to answer; you will not learn anything that way.
Finally, when you do have a specific problem, please post it to the correct forum. This forum is for questions on C#, not C.
Do you want to know more?
|
|
|
|
|
Hi!
I am writing a client/server application that uses sockets as the network interface. When I, in the client code, try to connect to the server by using BeginConnect with the wrong IP-address, my form freezes immediately and remains that way until an exception is thrown. Is there any way to prevent this from happening? Can I control how how long before the exception is thrown? I was using the construct below to solve the timeout issue, but that does not restore the state of my form. I assume the BeginConnect must be interrupted in some way, but I don't know if that can be done?
IAsyncResult connResult = this.remoteHost.BeginConnect(
remoteEndPoint, null, null );
// wait until the BeginConnect finishes
if ( connResult.AsyncWaitHandle.WaitOne(timeOut, false ) )
{
}
else
{
// WaitOne timed out
}
|
|
|
|
|
|
I would like to create a structure with fixed length strings. Is this possible?
For example the first element in the structure needs to be 20 characters etc.
Thanks for any help.
|
|
|
|
|
the code may me like this if u will control it in another method
struct urOne
{
string x = "";
}
void urMethod()
{
urOne.x = "asdfasdasd";
if (urOne.x.Length!= 20)
{
return
}
}
or do this method in the struct it self
ByMindOnlyYouCanDoIt
|
|
|
|
|
Hi all,
How should I mimic the ComboBox DisplayMember property which gets a string and can use the property whose name is indicated by that string.
Thanks in advance
|
|
|
|
|
When you know the name of the property, you can invoke that using Reflection (System.Reflection)
Type.GetType("MyType").GetProperty("MyProperty").GetValue
|
|
|
|
|
I am buIlding a library for developers so I dont know the type of the object.
And another problem , in GetValue Method there is an object and an array of indexes that I couldnt give a meaning.
Could you give me a real example please.
|
|
|
|
|
Hi,
I need to show the phone number of the caller in a c# program, I have CTI Meteor.
Any one can help?
Thanks
|
|
|
|
|
help on what? be more specific
IM PROUD TO BE A GMAIL;
|
|
|
|
|
Tom, thanks for response.
I need to make a program which can display the caller number when a phone call is recieved, having ofcourse the display modem attached to the COM port and the phone line, I have the modem (PC Caller ID).
Do you have any idea on how to show that?
Cheers
|
|
|
|
|
go to msdn or google hardware programming, im sorry i don't have time right now to do it my self
IM PROUD TO BE A GMAIL;
|
|
|
|
|
This is usually done through TAPI, if your modem supports it.
However TAPI and C# don't go very well together. You will be better off using C++.
However if you must try and use TAPI and C#, you are best off using this[^] as a starting point.
Michael
CP Blog [^]
|
|
|
|
|
Hi,
I just began learning c#, so I hope I am giving enough info with my question. I created a solution with two projects, in one I have an Mdi frame (with one namespace: boekhoud, and one class: frmContainer), in the other I have a child (with one namespace: ClientOnderhoud, and one class: frmClient). I set the parent-childrelation with
frmClient child = new frmClient();
child.MdiParent = this;
child.Show();
This compiles allright, so I can reference frmClient in my parent.
Now I would like to reference frmContainer in my child, I do this with
((frmContainer)this.MdiParent.MyConnection).Open();
It gives me the following error:
The type or namespace name 'frmContainer' could not be found (are you missing a using directive or an assembly reference?)
What should I do to let this work?
regards,
Stefan.
|
|
|
|
|
if projects are different then u have to:
1. add a reference to the Mdi Frame project in the child project. U can do this through the solution explorer >> Add reference >> and choosing the Projects tab.
2. Add a using statement at the beginning of ur child class file:
using boekhoud;
|
|
|
|
|
Ola Skynyrd,
I cannot add a reference to the mdi frame project, as it is no dll (I get an errormessage saying so if I try). I follow the rule 'an exe for the mdi, dll's for the childs'. With using boekhoud in my child cs I get 'The type or namespace name 'boekhoud' could not be found (are you missing a using directive or an assembly reference?)'
Any other ideas?
Gracias,
Stefan.
regards,
Stefan.
|
|
|
|
|
u need to have both projects under the same solution. Once u do this, u can reference projects through the projects tab even if they are .exe
Create a blank solution and add both projects to it. Then go to add references, and under the project tab of the Add References Dialog u will see that u can add a reference to the other projects of ur solution. DO NOT try adding it through the NET tab as u will get the exe error.
|
|
|
|
|
I have both projects under the same solution and I cannot reference the exe (mdiproject) in childproject. I get the errormessage stated in my previous mail. Any other ideas?
regards,
Stefan.
|
|
|
|
|
I'm sorry u are completely right...dunno what i was thinking about, cant reference .exe
I think ur best solution would be making ur container form implement an IContainerForm interface and include the Interface in your child dll.
Make any call to your parent MDI through the interface.
|
|
|
|
|
Thanks, this gives hope. Could you point me to or give a code-example?
regards,
Stefan.
|
|
|
|
|
Define a public interface with all public methods, events and properties that are not part of the base class Form of your fomContainer class and that u need to call from outside ur frmContainer's project. In your example we would have:
public Interface IContainerForm
{
SqlConnection MyConnection {get;}
}
Make ur frmContainer class implement the interface:
public class frmContainer:IContainerForm
{
}
When u need to call any particular method of your frmContainer instance from the child project, do it through the IContainerForm interface:
((IContainerForm)this.MdiParent).MyConnection.Open();
Obviously create the IContainerForm interface in your child project as u can reference this project from the frmContainer project and thus the Interface is available in ur containerform project.
Thats one of the reasons why Interfaces are used, it allows coders to share objects even before implementation is done. U are just sharing the public interface of your object that is basically all that u need when calling it from a different assembly.
I hope this solves ur problem.
P.D. Another solution would be to create a variable in youre childForm where u would store a reference to the parent's MyConnection. U could do this through a parameter in the childForm's contructor. This would be more code correct as you wouldn't be strongtyping the child's MDIParent and thus requiring that wherever u implement this class, its MDIParent must comply to certain conditions.
|
|
|
|
|
Thank you. I do not understand enough of interfaces to get my solution working yet, but found an interesting working solution at http://www.thecodeproject.com/csharp/SnapIn.asp with your pointer. It is not mdi, but easy adaptable. I'll spend some time on understanding that.
regards,
Stefan.
|
|
|
|
|
I have a picturebox control that I'm using the imagelist to draw one of two different images on. they're place in one of 24 different positions. the images draw great and look fine. The problem is if another window overlaps my picturebox, the images disappear. I'm new to C#, and I'm wondering should I be handling the form's paint event, or something different?
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|
try this in every handling for proposes problems this.refresh()
ByMindOnlyYouCanDoIt
|
|
|
|
|
I've made a class (CDot) that takes as its constructor's parameters two int's and an enum value that is defined inside the class. In my code when i try to make a new instance of the class, in the next call to add this to an arraylist, it crashes telling me "object reference not set to an instance of an object". I step through the code and put the object reference in the watch window, and sure enough, its values are all 0's. Any suggestions?
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|