|
Here's the question: textboxes themseleves already handle all these events so if I want to make a menu item that is going to do the same thing how do I get it to simply use the functionality that's already built into the textbox? If I put a menu on my form and add and edit menu that has Cut, Copy, Paste, etc and the default shortcut keys Ctrl X, Ctrl C, etc then the textboxes no longer have that functionality.
So the question is how do I get my menu commands to simply use the textboxes already built-in functionality?
Thanks for the help.
- Aaron
|
|
|
|
|
monrobot13 wrote: If I put a menu on my form and add and edit menu that has Cut, Copy, Paste, etc and the default shortcut keys Ctrl X, Ctrl C, etc then the textboxes no longer have that functionality
My guess would be that you are overriding the default textbox menu with your own, so in essence this is why you're disabling the default behavior. So if this is the case, I guess you would have to re-implement this kind of behaviour in your new menu. I don't know whether you can merge the default functionality with your own. But then again, why on earth would you want to do that?? Correct me if I am wrong, but it's like re-inventing the wheel... isn't it?
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
In C#, is it possible to pass a parameter to a function receiving pointers. A simple example
int somefunc(int* i)
{
return *i;
}
Is it possible to call a function like this in C#?
|
|
|
|
|
No, but you can use the ref or out keywords to achieve similar results.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
Or are you talking about calling a native function? In which case you can set up an unsafe block of code and use pointers there. However, you have to change the options in your assembly as unsafe blocks not supported by default.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
Thank you guys!
It is a DLL created from VC++.Net with this native type int, I thought int in VC.Net is just an alias of System.Int32. Since I want to pass the results back from DLL to the C#. C# see it only as a pointer.
The VC++.Net functions are like
int Somefunction(int& i)//Passing by reference
{
int iother = OtherFunction(&i);
}
int OtherFunction(int* j)//passing by pointer
{
*j=5;
return 0;
}
To receive the change in i, how actually I can use either ref or unsafe block?
C# is really new to me, would you please give me some sample code to call function Somefunction to get the result in i?
Thanks a lot!
Devin
|
|
|
|
|
Assuming for an example that your dll is called Foo.Dll. You would need C# code like the following
<br />
public class SomeClass<br />
{<br />
[DllImport("Foo.Dll")]<br />
public static extern int OtherFunction(ref int j);<br />
<br />
public int SomeFunction(ref int i)<br />
{<br />
int iother = OtherFunction(ref i);<br />
}<br />
Adding the "ref" keyword is like having int& in C++. When you're calling into native code though it's like it was a *.
Jared Parsons
jaredp@beanseed.org
http://spaces.msn.com/members/jaredp/
-- modified at 17:40 Monday 12th December, 2005
|
|
|
|
|
Thanks for the help. I mean the DLL is generated by C++ . If both DLL and the application are in C#, I think this is the way to do it.
Devin
|
|
|
|
|
Hello.
I was wondering if anybody knows how to sign the assemblies generated by CodeDom?
(The ones generated in memory, not the ones saved to the HDD)
-Chris
|
|
|
|
|
|
I have a datagrid that I populate by:
<br />
OleDbConnection dbConnection = new OleDbConnection(); <br />
OleDbCommand tableCommand = null;<br />
OleDbDataReader reader = null;<br />
dbConnection.ConnectionString = sConnString;<br />
dbConnection.Open();<br />
tableCommand = dbConnection.CreateCommand();<br />
tableCommand.CommandText = sSQL;<br />
<br />
DataSet ds = new DataSet(); <br />
OracleDataAdapter adapter = new OracleDataAdapter(); <br />
adapter.SelectCommand = tableCommand;<br />
adapter.Fill(ds, "AllPatients"); <br />
dataGridPatients.SetDataBinding(ds, "AllPatients");
This works fine. I alter sSQL based on selections made on a Windows form. However, when I execute this code a second (or third) time, the selected Datagrid cell retains its original value until I select the cell again.
Assuming the current datagrid row is:
1|Bob|Jones|
and Jones is selected, loading a dataset that contains 3|John|Smith|
results in
1|John|Jones|
being displayed. However, as soon as I select (manually) the Jones cell, Smith displays.
If I have several rows displayed origianally, and select a cell in a row greater than the number of rows displayed the next time, that cell remains in the datagrid.
What do I have to do to get the previously selected cell from retaining its selection? I have tried to unselect the row, to set current cell to something else, and to simulate a mousedown on the selected cell (which fires, but doesn't actually change the current visual cues).
Thanks,
Glenn
|
|
|
|
|
Hi, I am new to C#, I have just switched to C#, because there are more web resources on C# than VB, I am having a problem related to UDP data Receiving. I want to know, what is necessary information to receive UDP Data? Actually, My City Stock Exchange sends the UDP Data to their Clients on Port# 8129, but my code does neither return any data nor any error. I don’t know much about the server, which sends the data. My source code works fine locally.
Patch of this coding is given below:
<code>IPHostEntry localHostEntry;
try
{
Socket soUdp = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
localHostEntry = Dns.GetHostByName("127.0.0.1");
IPEndPoint localIpEndPoint = new IPEndPoint(localHostEntry.AddressList[0], 8129);
soUdp.Bind(localIpEndPoint);
while (true)
{
Byte[] received = new Byte[200];
IPEndPoint tmpIpEndPoint = new IPEndPoint(localHostEntry.AddressList[0], sampleUdpPort);
EndPoint remoteEP = (tmpIpEndPoint);
int bytesReceived = soUdp.ReceiveFrom(received, ref remoteEP);
String dataReceived = System.Text.Encoding.ASCII.GetString(received);
Console.WriteLine(dataReceived);
}
}
catch (SocketException se)
{
Console.WriteLine("Socket Exception has occurred!" + se.ToString());
}</code>
|
|
|
|
|
When you bind the 127.0.0.1 you are creating a looback binding that is available on your machine only. The loopback address is a special IP that bypasses the core logic of TCP/IP driver so that messages can simply be routed intra-machine w/o having to undergo the packet processing required for inter-machine communication. Thus you can start by creating an end point to the actual IP address. Now if your computer uses DHCP to acquire an IP then you will have to deal with passing it as a command line or windows form parameter, or possibly just use a static IP instead. Secondly since UDP is connectionless why are you binding the socket? Finally go with the Managed UDP interface unless you truely have a reason to drop down to the native socket interface.
All you really need for UDP is:
UdpClient client = new UdpClient(8129);<br />
<br />
IPEndPoint remoteEndPoint = new IPEndPoint(0,0);<br />
<br />
byte[] datagram = client.Receive(ref remoteEndPoint);<br />
string dataReceived = System.Text.Encoding.ASCII.GetString(datagram);<br />
<br />
string request = "Thanks";<br />
byte[] packet = System.Text.Encoding.ASCII.GetBytes(request.ToCharArray());<br />
client.Send(packet, packet.Length, remoteEndPoint);<br />
Good luck with C#
Mike Luster
|
|
|
|
|
Im trying to run Thoughtpost.P2P library
but even the examples dont want to run
it throws some exception could it be because of me using .Net Framework 2?
Could i use C# Express 2005 and compile throw .Net framework 1.1 ???
Thanks !
|
|
|
|
|
It probably doesn't work because it's written for .NET 1.1. No, you can't use Visual Studio 2005 with .NET 1.1, not even the Express versions.
You MUST use Visual Studio 2003 with .NET 1.1. Or Notepad... It's just a matter of preference.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Any idea if i cant have both, 2003 and 2005 express editions installed ?
|
|
|
|
|
Installing multiple versions of both the .NET Framework and Visual Studio is not a problem. You just have to make sure they're installed in the correct order.
I don't think there is a 2003 Express edition, just 2005.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I've made two Windows Services that communicate between them and I get a lot of exceptions with the message 'An existing connection was forcibly closed by the remote host'.
I've searched in other forums but without any good answer. Do you have any idea?
Thanks
Ricardo
|
|
|
|
|
|
The problem is that this error is occurring on the server. There are a lot of clients connected to it and the clients stay connected.
|
|
|
|
|
If the error is occuring on the server then one of the client's actively closed their socket. This happens when the client closes the socket or the process crashes (in which case the kernel closes out the socket).
Jared Parsons
jaredp@beanseed.org
http://spaces.msn.com/members/jaredp/
|
|
|
|
|
Maybe there is another problem. Look what is happening: I have the following methods:
internal void SendData(Channel channel, byte[] buffer, int offset, int count)
{
if(channel != null && channel.Socket != null && channel.Socket.Connected)
channel.Socket.BeginSend(buffer, offset, count, SocketFlags.None, new AsyncCallback(OnDataSent), channel);
}
private void OnDataSent(IAsyncResult asyncResult)
{
if(asyncResult != null && asyncResult.AsyncState != null)
{
Channel channel = (Channel)asyncResult.AsyncState;
ushort bytesSent = (ushort)channel.Socket.EndSend(asyncResult);
...
}
}
The Channel class is a custom class that holds a reference to a Socket object. First I call the SendData method, that calls the BeginSend method on the Socket object. When the socket ends sending the data, it calls the OnDataSent method. The problem is that when I try to call the EndSend method, the Socket object is null. I don't have any control over it once is the framework that calls the method. When I don't test if the Socket object is a null reference, I get the NullReferenceException. When I test, I get the other exception (the SocketException).
In other words, all the problems reside in the fact that the Socket object is null. Do you have any idea about what could be causing this behaviour? Could the network topology have any influence?
Thanks.
|
|
|
|
|
This looks like it may be a race condition. OnDataSend is called on a different thread than BeginSend. Is your Channel class thread safe?
When you say test and not testing your app are referring to attaching a debugger? If so then it's almost certainly a race condition.
Jared Parsons
jaredp@beanseed.org
http://spaces.msn.com/members/jaredp/
|
|
|
|
|
I have been reading from various sources about delegates. The more I read the more I get confused.
My question is - What can you do with delegates that you cannot do with just calling the method and not using delegate(s) howsoever?
I mean assume that when an event occurs then instead of having a delegate call the method just call the method directly from the event handler.
Also if you can send any good link that explains the concept it will be appreciated.
Thanks
----------
Venus Patel
http://patelsinc.blogspot.com/
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
I am sure there are other advantages, but the one that comes to mind is this:
Say you create a control dynamically. Since it is not created at design time, you have no other way to associate your sub with your control. What you need to do is create your delegate, and when you create your control at runtime, associate the delegate with the controls method call.
Hope this helps.
Roy.
|
|
|
|