|
|
I have a window form that contains a textbox. I've hooked into the Validating event of the text box to check that the text is valid and prevent the textbox from lossing focus until valid text is typed. The problem is that if the user clicks a button on the toolbar it completely avoids this validation and this allows the user to get away with invalid input. Is there anyway to prevent this from happening?
|
|
|
|
|
yeah, when user click the button it will generate the required event. so you need to do error checking(validation) in the click event method of the button too.
|
|
|
|
|
So I have to repeat the validation of ALL the controls on my forms when somebody clicks on the toolbar? I'm starting to think the toolbar might not be worth the effort!
|
|
|
|
|
That shouldn't happen! The Validating event is supposed to fire *before* the control loses focus.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
But it does. I just tried it again on a simple application (in case it was something I was doing). I created a form with a textbox, a button and a toolbar with one button. I hooked the textbox validating and the toolbar button like this:
<br />
private void textBox1_Validating(object sender, System.ComponentModel.CancelEventArgs e)<br />
{<br />
MessageBox.Show("VALIDATING TEXTBOX");<br />
}<br />
<br />
private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)<br />
{<br />
MessageBox.Show("CLICK");<br />
}<br />
Now when you run the app and click in the textbox and then tab away (to the regular button) or click the regular button, the VALIDATING messagebox will popup. But if you click the toolbar button, you only see the CLICK messagebox!
|
|
|
|
|
I think the problem is caused because the Toolbar doesn't take the focus away from any controls in the application. An act required for the validation event to fire.
You can fake validation by setting the focus to another control then restoring it. If you just drop a Panel onto your form then you won't even have to deal with something that is visible.
Something like this at the beginning of your ButtonClick event of your ToolBar should work:
Control control = ActiveControl;
if( control != null )
{
panel1.Focus();
if( control != ActiveControl )
{
control.Focus();
}
} HTH,
James
"then when you go to bed...wait, you dont do that do you....ok....when you plug into the 'hive mind' to charge yourself, ill hack into your head"
Nnamdi Onyeyiri over MSN
|
|
|
|
|
Thanks. I was thinking I'd probably have to do something like that, but I was hoping there might be a more elegant solution.
|
|
|
|
|
I am trying to make a wizard type application. For example, an install application will have multiple forms with a next button to go to the next form. The problem is that I don't know how to jump from form to form without the form being closed and removed from the start taskbar and the next one loaded. This causes continual movement in the taskbar, which is both anoying and potentially confusing to some users. Does anyone know how to go from form to form while keeping the same button in the start taskbar? I have tried to do a MDI type solution but it seems to be more of a pain. Just wondering if there is a typical way to do this.
Mark Sanders
|
|
|
|
|
I can think of a couple of ways you could do this:
The ShowInTaskbar property of a form will prevent it from displaying in the taskbar (when it's set to false). So you could have one blank form, set it to start minimized and prevent it from being maximized, then use that form to open all your other forms (which all have ShowInTaskbar = false) as you need them. No taskbar jiggling should happen.
I think a better way to do it would be to forget about having multiple forms entirely and have just one form with a tab control. You can disable all the tabs so that the pages only get changed programatically when the user clicks the next button. The downside is if you wanted each form to be a different size, although you could make it resize through code it would be a pain to design.
|
|
|
|
|
with regards to the Tab Control solution, is there a way to disable showing the tabs in the form?
thanks
|
|
|
|
|
Hi everyone. I have been creating an application under .NET 2002. I have recently installed .NET 2003 and converted my solution to 2003. I have noticed the following 2 "oddities":
1. Data will not load into a ComboBox that is bound to data from a database and has the Sort property set to true. In .NET 2002, this is okay, at least for the control that had the problem under .NET 2003. I did have some problems with setting Sort to true on a data-bound ComboBox. Workaround: Turned Sort off on that control. All other ComboBoxes load fine with no changes.
2. There are 2 ListBoxes next to each other. The left one is filled with options from the database. When double-clicking an item in the left list, it is removed and then added to the ListBox on the right. However, under .NET 2003, the first entry does not become visible until I add a second item. Workaround: I removed the BeginUpdate and EndUpdate calls from around the double-click logic and it works fine.
So, has anyone see any weird stuff like this? Not major, but I find it odd that the functionality for these has changed like this. The documentation for each item above is the same under .NET 2003, so I think they are bugs. Also, how do I submit bugs to Microsoft without using up my incidents for the year?
BTW, everything functions fine under .NET 2002.
Thanks
abbomar
|
|
|
|
|
i have been trying to figure out a way to send this xml data to ups for rate quotes.
the goal here is to connect to this url, and send data. then receive the data it sends back.
i get an exception because i'm trying to connect to a url ( and subdirectories ) instead of an IP.
how do i connect to this url and send the data to the appropriate place?
here is an example of what i'm attempting:
TcpClient tc=new TcpClient("https://www.ups.com/ups.app/xml/Rate");
NetworkStream ns=tc.GetStream();
StreamWriter sw=new StreamWriter(ns);
sw.WriteLine(xml);
sw.Flush();
StreamReader sr=new StreamReader(ns);
txtResponse.Text = sr.ReadLine();
|
|
|
|
|
I've got a class that does this, it's in hands of editor right now. Don't know when he's going to release it.
Anyway, if you want help, you need to first let us know what the exception was.
norm
|
|
|
|
|
thanks for the reply, .. here is the exception:
System.Net.Sockets.SocketException: The requested name is valid and was found in the database, but it does not have the correct associated data being resolved for
at System.Net.Dns.GetHostByName(String hostName)
at System.Net.Dns.Resolve(String hostName)
at System.Net.Sockets.TcpClient.Connect(String hostname, Int32 port)
at System.Net.Sockets.TcpClient..ctor(String hostname, Int32 port)
at ups.Form1.btnSend_Click(Object sender, EventArgs e) in c:\visual studio projects\ups\form1.cs:line 202
|
|
|
|
|
Did you try:
1. TcpListener must start listening before TcpClient attempts to connect.
2. Try connect to "localhost" or "127.0.0.1"
3. Port number specified - is it available or has it been taken?
norm
|
|
|
|
|
the same script connects to 'localhost' just fine.
i think my problem is connecting to https://www.ups.com/ups.app/xml/Rate
if i just use "ups.com" , it connects, but then it hangs because ideally i need to send the data to the "ups.com/ups.app/xml/Rate" application so my app can receive data back.
once i create the connection, is there a way to navigate to the 'Rate' app before i send the data?
|
|
|
|
|
I can't answer your question. If you can connect to your localhost and not to a remote address, ten thousand things can go wrong. I don't think the fact that UPS application is expecting some data (perhaps password) has anything to do with whether or not its TcpListener accepts or reject your call - it must accept the incoming connection (TcpClient) before it can accepts anything it expected. Therefore, should there be a problem, it shouldn't be this. If it is indeed expecting some data, say userID/passed, it should first TcpListener.AcceptConnection. Then, the application should read from the network stream - if it can't find the expected data, drop the connection. But in this case, it has already accepted the connection before it drops it - therefore, Connect shouldn't fail. But TcpClient.Send(...) will - you can't send to a closed socket.
norm
|
|
|
|
|
thanks, but i think i am miscommunicating here.
i can connect to ups.com , .. just not the 'Rate' program the UPS documentation calls for me to request information from.
all the authentication is done in the xml string i'm sending to them.
the problem seems to be with me trying to connect to a sub directory of a domain.
so i am probably supposed to connect to ups.com , .. but i must figure out how to send the data to that Rate app in the sub directories.
thanks a lot for your time though!
|
|
|
|
|
no problem. Sorry I can't be of any help here. Good luck.
norm
|
|
|
|
|
Ack - norm, did you actually understand his code at all?
--
-Blake (com/bcdev/blake)
|
|
|
|
|
|
I'm afraid you are using entirely the wrong tool for the job. URL's and Ports are in no way interchangable. You need to be using WebRequest not TcpClient. TCP is a stream protocol between an IP address/port pair on one computer and a IP address/port pair on another computer. HTTPS is an application level protocol between that runs inside an encrypted tunnel that's inside a TCP connection.
Since you are sending XML to this URL I suspect it is a web service of some flavor, and even easier you should be using a proxy generated from their WSDL description of the service.
--
-Blake (com/bcdev/blake)
|
|
|
|
|
Hi, do we need to implement our own DataGrid paging for Windows Form DataGrid?
I understand that to implement paging for ASP.NET DataGrid, one simply specify: InPageIndexChanged handler as DataGrid's attribute.
But anyone did that for WindowsForm?
Thanks!
norm
|
|
|
|
|
Does anyone out ther know how to work around the problem that Interops (Office one for sure) cannot be included in assemblies that are strong named?
|
|
|
|