winform: checking for text changed

on my form, i have a listview and a textbox above it. I have Apply, OK, Cancel buttons.

Apply button is disabled.

When user double clicks a listview item, I put that item in the textbox. Now, if user changes that textbox text, I have to enable the Apply.

So, I used "TextChanged" event. I double click a listview item, puts it in the textbox and the Apply button is enabled. BUT, I havent changed the text yet. I know why the Apply button is enabled...because the previous textbox value was blank and now it's something new.

*** But I want the Apply button to change ONLY if that text is actually changed by the can I do this??
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

my be something like

on textchange_event()
   if (listview.selectedtext != textbox.text)
         //enable apply button


hope i have understood your problem correctly

You can solve this by:
1. Create a class-level boolean member, say:
private bool JustLoaded = false;

2. In your double-click handler, before you populater textBox.Text with the new value,
JustLoaded = true;

3. In you textChanged handler,
if (JustLoaded)
   JustLoaded = false;
   // Do your textChanged processing.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jaime OlivaresSoftware ArchitectCommented:
You cannot know if the textchanged event is produced programatically or manually.
Simplest way is to Disable the Apply button manually after copying the text from the listview.
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

CamilliaAuthor Commented:
let me read and will post back. Thanks.
Why not set LabelEdit = true on the ListView, and then handle the AfterLabelEdit event?
CamilliaAuthor Commented:
Jim's solution worked.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.