473,385 Members | 1,973 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 1583
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.WriteLine() 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.WriteLine() 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
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....
2
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...
4
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...
2
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...
3
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...
2
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...
12
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...
4
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...
2
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...
2
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 ...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...

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.