473,748 Members | 8,367 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with Textbox and File-Save

I'm developing a WinForms app and have a slight problem that I hope someone
can help me with. There are a series of textboxes that the user can enter
information into. The text in these boxes is only copied into the data model
when the textbox's LostFocus event is fired. This has worked well so far.

But I've just noticed that if the user enters some text into a textbox and
then goes up to File-Save (on the parent form) that the newly entered text is
not saved. This is obviously because this event is not causing the LostFocus
event to be fired.

I think there might be several ways to resolve this issue but am seeking
advice from those of you who have encountered the same problem before.

--
Robert W.
Vancouver, BC
www.mwtech.com

Nov 17 '05 #1
2 1628
I was about to respond that I could not get this to work as you described...
but then I tried it another way and it did end up the way you said, always
interesting the difference between using MessageBox.Show () and
Console.WriteLi ne() when it comes to timing.

Best way I’d suggest, would be to do a this.Focus() within your MenuItem’s
Click handler, just before you do any of your actual saving work. This would
take focus away from the current TextBox and force it to update via your
existing methods.

Brendan
"Robert W." wrote:
I'm developing a WinForms app and have a slight problem that I hope someone
can help me with. There are a series of textboxes that the user can enter
information into. The text in these boxes is only copied into the data model
when the textbox's LostFocus event is fired. This has worked well so far.

But I've just noticed that if the user enters some text into a textbox and
then goes up to File-Save (on the parent form) that the newly entered text is
not saved. This is obviously because this event is not causing the LostFocus
event to be fired.

I think there might be several ways to resolve this issue but am seeking
advice from those of you who have encountered the same problem before.

--
Robert W.
Vancouver, BC
www.mwtech.com

Nov 17 '05 #2
Brendan,

This is one of those "Why didn't I think of that?!?" moments!

Simple and effective and does EXACTLY what I want!

Thank you so much and have a great weekend!

--
Robert W.
Vancouver, BC
www.mwtech.com

"Brendan Grant" wrote:
I was about to respond that I could not get this to work as you described...
but then I tried it another way and it did end up the way you said, always
interesting the difference between using MessageBox.Show () and
Console.WriteLi ne() when it comes to timing.

Best way I’d suggest, would be to do a this.Focus() within your MenuItem’s
Click handler, just before you do any of your actual saving work. This would
take focus away from the current TextBox and force it to update via your
existing methods.

Brendan
"Robert W." wrote:
I'm developing a WinForms app and have a slight problem that I hope someone
can help me with. There are a series of textboxes that the user can enter
information into. The text in these boxes is only copied into the data model
when the textbox's LostFocus event is fired. This has worked well so far.

But I've just noticed that if the user enters some text into a textbox and
then goes up to File-Save (on the parent form) that the newly entered text is
not saved. This is obviously because this event is not causing the LostFocus
event to be fired.

I think there might be several ways to resolve this issue but am seeking
advice from those of you who have encountered the same problem before.

--
Robert W.
Vancouver, BC
www.mwtech.com

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
5082
by: Max | last post by:
Suppose we have an object hierarchy in XSD. For example, let us take Control, Label, TextBox and LinkLabel windows controls. Each control has some properties which are represented as elements. Some of the elements are of complex types as well, like bounds - of type rectangle. (See full example in the bottom of the letter.) DataSet.ReadXMLSchema fails to parse such XSD file. The problem is caused by complex type as an element of the...
2
1825
by: Cory | last post by:
I have a very strange problem with my C# code. I trying to add a file to my dataset. I use a openFileDialog object to get my file. I put the file pathname in a textbox. Then i click my upload button which adds my file to the dataset and then writes the dataset to a XML file(ds.writeXML ("test.xml");).I know the file is added to the dataset but it doesn't get written to the XML file. The strange thing is if i type the file pathname in the...
4
2923
by: Rodrigo DeJuana | last post by:
Howdy, I'm new to this .net stuff and really have little to no training. Im trying to create a new page for a web form, so i have been pretty much jsut coping code. I having some issue with some textboxes not updating when i a hit save. for example I have this code in my aspx.cs file: declared:
2
1814
by: dlgproc | last post by:
Hi In my Windows Form application I created a File Browser control that was derived from System.Windows.Forms.UserControl. It contains a single line text box and a button. The user can enter a filename in the text box or hit the browse button, popup the File Open Dialog box, and select a file. The subsequent selection is placed in the text box. We've seen this type of control everywhere so I'm not sure why it's not a standard control in...
3
4870
by: Kris van der Mast | last post by:
Hi, I've created a little site for my sports club. In the root folder there are pages that are viewable by every anonymous user but at a certain subfolder my administration pages should be protected by forms authentication. When I create forms authentication at root level it works but when I move my code up to the subfolder I get this error: Server Error in '/TestProjects/FormsAuthenticationTestingArea' Application.
2
1863
by: Mad Scientist Jr | last post by:
i'm trying to read a file byte by byte (and later alter the data and write it to a 2nd file byte by byte) and running into a problem where it seems to keep reading the same byte over and over again (an endless loop). i thought that BinaryReader.ReadByte advanced to the next byte? i had it time out after 1000 iterations, and keeps outputting the same byte. any help appreciated, my code is below: Imports System.io
12
5133
by: Joel Byrd | last post by:
I'm having a little problem with using type-ahead functionality for an auto-suggest box. Sometimes, when I start to type something and the type-ahead shows up, the AJAX will send a request query using the value that *includes* the type-ahead value. In other words, say that I type in "ja" and the first listing that comes up is "jack@test.com". The AJAX part is supposed to send "ja" as one of the query string variables when calling the...
4
2704
by: Nina | last post by:
Hi everyone, I try to a display a .txt file in window's textbox or rich textbox. The text file has contents line by line aligned perfectly when using NotePad to view and print it. But when I display this .txt file in textbox or rich textbox the alignment all messed up. Please help me to solve this problem. Thanks in advance. Nina
2
2960
by: DC | last post by:
The Code <%@ import namespace="System" %> <%@ import namespace="System.Web" %> <%@ import namespace="System.Web.UI" %> <%@ import namespace="System.Web.UI.HtmlControls" %> <%@ import namespace="System.Web.UI.WebControls" %> <%@ import namespace="System.Data" %> <%@ import namespace="System.Data.OleDb" %>
2
6968
by: pankajsingh5k | last post by:
Dear All, Please help me... I had read an article to lazy load a tab in a tabcontainer using an update panel on http://mattberseth.com/blog/2007/07/how_to_lazyload_tabpanels_with.html and i am implementing it in my website....
0
8984
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8823
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9530
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9312
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4593
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.