|
if_mel_yes_else_no wrote:
You can fake it pretty easily. When the MenuItem catches a mouseDown
The problem is that a MenuItem doesn't have standard MouseDown/Up/Move events. It just has a Click event whose parameter is a plain System.EventArgs not MouseEventArgs so I don't have access to the information that would be in MouseEventArgs. Without being able to detect if I have a left or right-click or if the Ctrl key is pressed I don't see how to tell the difference between a normal click on a MenuItem and the click that is to start the drag operation.
Thanks,
Bill
|
|
|
|
|
You must be using studio 2003. In studio 2005 the MenuItems have all the mouse events. There's a chance that you could look into having the application catch any system mouseDowns, and using the mouseEventArgs's X and Y coordinates, try to figure out if it came from your menuItem... but that sounds like a lot of hassle.
How about a seperate menu item called "Add Bla". After you click it the cursor changes as I said before, and you can click on the receiver. It's not exactly a drag so much as a 'click to place', but it's better than nothing.
|
|
|
|
|
Yes, I am using studio 2003. I think we will wait for the final release of studio 2005 before adding drag & drop to our menus.
Thanks for your help,
Bill
|
|
|
|
|
I wrote a program with a whole bunch of tabs and each tab has subtabs with a bunch of controls in them. I distributed the program inside my company and some users complained that the text is cutoff on some controls. I asked for a snapshot and what happens is that the text wraps around on some of the controls and since the users are not aware of the wrap around feature to them it looks like the text is cut-off on top and on bottom.
Any ideas on how I can fix this problem so my GUI looks the same on all computers?
|
|
|
|
|
Welcome to the world of compatability. Trying to get an application to look the same on all computers is near impossible unless everyone in the company has the same type of operating system. If you're using studio 2005 and C# then the tab control's headers should auto-size to the length of the text. In 2003 I think you have to set auto-size yourself, either that or there will be a property called WordWrap that you can set to false.
|
|
|
|
|
Thanks for the reply; however, my main problem is that the text in miscellaneous controls such as checkboxes and labels are getting wrapped around even though they look fine on some computers.
Reason I mentioned about the tabs and subtabs is that I have way to many controls to modify them one by one, so I am hoping there is some method to make the GUI look the same on all PCs.
Your input about the OS is very good, I will check to see if that is the reason. Hope that's it because eventually everyone should go to XP.
Thanks.
|
|
|
|
|
Make your app check the screen resolution and inform users if it's too low. Or, find out the lowest screen res your users have, and develop at that res.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks Christian, I should be able to get feedback on the resolution of all the users who are having problem and hopefully I can see a pattern to solve the problem.
Regards,
Rudy.
|
|
|
|
|
hi,
the text in the rich textbox is underlined!
when i enter a key in the textbox i want to have FontStyle.Regular:
<br />
private void textBox_Receivers_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)<br />
{<br />
textBox_Receivers.SelectionStart = 0;<br />
textBox_Receivers.SelectionLength = textBox_Receivers.ToString().Length;<br />
textBox_Receivers.SelectionFont = new Font("Arial",8,FontStyle.Regular);<br />
}<br />
but when i enter only the one char (the one which i pressed) is in the textbox...why, the other text is cleared!? whats wrong?
cu
-- modified at 16:31 Tuesday 30th August, 2005
|
|
|
|
|
The text box is doing exactly what all text boxes do when all the text is selected and you insert a letter. It takes the selected text and replaces it whith the new letter. You really shouldn't be surprised by your results.
If you want to change the font and attach the new letter, then you need to clear your selected text before you leave the method.
|
|
|
|
|
|
SelectionLength = 0;
That's the first thing that came to my mind. There are also arguments in the 'e' parameter that you can use. Cancel pretends the keydown never happend, sometimes called Suppress.
|
|
|
|
|
<br />
private void textBox_Receivers_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)<br />
{<br />
textBox_Receivers.SelectionStart = 0;<br />
textBox_Receivers.SelectionLength = textBox_Receivers.Text.Length;<br />
textBox_Receivers.SelectionFont = new Font("Arial",8,FontStyle.Regular);<br />
textBox_Receivers.SelectionLength = 0; <br />
}<br />
doesn't work...hm
cu
|
|
|
|
|
richTextBox1.SelectionStart = 0;
richTextBox1.SelectionLength = richTextBox1.Text.Length;
richTextBox1.SelectionFont = new Font("Arial", 8, FontStyle.Bold);
richTextBox1.SelectionStart = richTextBox1.Text.Length;
richTextBox1.SelectionLength = 0;
This works fine when I do it.
|
|
|
|
|
hi, thx perfect, but i have a problem
if i select the whole text in the richtextbox and press clear or backspace then the whole text isn't cleared...hmmm!?
but i think i also can do that with Rtf, i mean that with underline...? how?
i saw:
<br />
textBox_Receivers.Rtf ...<br />
by the time i like c# *hehe*
cu
|
|
|
|
|
Rtf is just the same text but with the formatting codes included. You would never want to set the font on your Rtf. The codes will never be seen. If you're asking how to do underline, it's part of the FontStyle just like Regular and Bold.
|
|
|
|
|
if i select all the text in the richtextbox and if i press clear or backspace then all the text isn't cleared...hmmm!?
why?
cu
|
|
|
|
|
Come on, that one is pretty obvious don't you think?
|
|
|
|
|
I need to know how would i remotely call methods on another pc(program) when my database(sql) changes(update occurs).I need to notify my viewing program(GUI) of the changes allowing immediatly show the changes as the database changes. How would this be done in C#. Triggers? I am very new to C# links to some nice tuts would be helpful as well as any other suggestions on how i would tackle this. Thank you
|
|
|
|
|
There are plenty of ways I'm sure, but I've always had the best success with custom TCP protocols. Meaning, you would connect to the remote computer through a TCP Client on a dedicated port, and send your own message format to the remote computer. The remote computer should have a thread that is constantly listening on that port for new connections. When it receives your connection, it verifies that it came from you (your custom message format should have a username/password in it), and performs the necessary operation based on the message. This approach has yet to fail me.
|
|
|
|
|
that sound great, is there perhaps some links to samples explaining in more detail, as i said i am new to programming. thanx again
|
|
|
|
|
If you've never set up a TcpClient, studio 2005 makes it pretty easy. Same for the TcpListener on the remote computer.
//DataBase Computer
TcpClient m_connection = new TcpClient("15.3.6.33", 17534);
StreamWriter m_writer = m_connection.GetStream();
m_writer.WriteLine("(app)(username)mel(/username)(password)mel(/password)" +
"(command)REFRESH(/command)(/app)");
//Remote Computer
TcpListener m_listener = new TcpListener(17534);
TcpClient m_connection;
StreamReader m_reader;
String strCommandText;
m_listener.Start();
while(true)
{
if (m_listener.Pending())
{
m_connection = m_listener.AcceptTcpClient();
m_reader = m_connection.GetStream();
strCommandText = m_reader.ReadLine();
// Now parse your message to find out what you should do.
}
}
-- modified at 18:16 Tuesday 30th August, 2005
|
|
|
|
|
Hi there,
I'm writing a Client/Server program that relied on Tcp Communication.
the problems begin when one of the clients that already connected to the server decide to disconnect (shut down the program or because of an error).
the thing is that before he decide to disconnect his status is "Connected" (at the database)
and after that, when the client has disconnected, the socket keeps on being opened for at least 60sec because of that the client cannot reconnect to the server
(and because the server couldn't tell if the client has been disconnected or not so his status is still "Connected").
What can i do?
can i raise any event that will tell the server that one of the clients has disconnected himself?
pls, need help...
thanks...
|
|
|
|
|
I have still not seen any events that you can listen for when it comes to the socket class. What I do is to have a thread that is dedicated to doing nothing other than checking my array of socket connections. If it ever finds a connection that was closed from the remote end, it calls the necessary method. That's with C#.. I've done development in C++ with QTSockets, which do (God bless them) have events for socket disconnection.
|
|
|
|
|
Hi!
The TcpClient has timeout properties and a LingerState property that controls if and for how long the underlying socket is kept open.
Perhaps twiddling with these will help you closing the socket immediately.
Regards,
mav
|
|
|
|