[dba-VB] c# text box changed event

Shamil Salakhetdinov shamil at smsconsulting.spb.ru
Tue Sep 29 14:47:33 CDT 2009


Hi Gustav,

The course I'm taking is called "Intermediate C#". :) 
I just didn't find "advanced" or "guru" course - and therefore I have taken
the most complicated one.
Yes, it's easy but I must admit I've learned some new stuff after the first
four lessons - mainly by developing simple on first glance assignments. So
it's not waste of time or money.
And I like the way they introduce C# to beginners/intermediate level
developers.
I'm learning how they do that.
Maybe one day I will go tutoring/coaching C#.
And certificate they give - it can bring some new projects to me.
And if that course will prove it's worth USD99 I spent on it I will take
some other courses from them in the new areas to me.

BTW, for the subject task I'd use context custom flag variables.

Thank you.

--
Shamil

-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Gustav Brock
Sent: Tuesday, September 29, 2009 5:45 PM
To: dba-vb at databaseadvisors.com
Subject: Re: [dba-VB] c# text box changed event

Hi John

So you and Shamil have joined a club recapturing your knowledge at
beginner's level? Interesting.

As for the code, in my scenario it worked because the textbox never had
focus when browsing records; focus was at a button or a toolbar or
previously moved off the textbox by some other code. On the other hand, if
the user types into to textbox it will have focus.
This:

            TextBox textBox = (TextBox)sender;

does nothing more than casting the sender object to a variable of type
TextBox without using the name of the textbox control making it easier to
copy and paste the code to other textboxes. For other types of controls you
will need to adjust the code, say:


           CheckBox checkBox = (CheckBox)sender;

What confuses us it, that "changed" here is different from Access. Here it
happens whenever the data (text) displayed in the textbox changes - manually
or when browsing records. In Access it only happens when the user types into
the textbox.

/gustav


>>> jwcolby at colbyconsulting.com 29-09-2009 15:14 >>>
Gustav,

 > Are we allowed to help with homework?

LOL.

The homework does not involve classes, collections, or even the messagebox
(all used in my version 
of the homework) because we don't even get to that until next semester.  I
am just trying to 
entertain myself and learn something beyond "how does the string object
work".

This is a first semester C# programming class.  We use Murach's C# 2008, and
we are currently on 
chapter 4 - How to work with numeric and string data.

That is a cool method of discovering the source of the change event.  I have
too admit though that I 
don't fully understand it.  It seems that you are casting the sender to a
textbox type?  Why don't 
we error if this is not a text box type?  And whatever caused the change has
the focus, so why 
doesn't the object (once cast) always say that it has the focus?

I'm confused.

John W. Colby
www.ColbyConsulting.com 


Gustav Brock wrote:
> Hi John
> 
> Are we allowed to help with homework? Some forums explicitly prohibits
this! The idea behind homework - ask your teacher - is quite often that you
are supposed to work out a solution by yourself as a challenge for your - eh
- limited resources!
> 
> Anyway, I had the same issue and worked out this very simple method:
> 
> <code>
>         private void textBoxName_TextChanged(object sender, EventArgs e)
>         {
>             TextBox textBox = (TextBox)sender;
>             if (textBox.Focused)
>             {
>                 Console.WriteLine(textbox.Text);
>             }
>         }
> </code>
> 
> /gustav
> 
> 
>>>> jwcolby at colbyconsulting.com 29-09-2009 04:26 >>>
> No.  I am doing a homework assignment where I collect grades in classes,
and then move back and 
> forth through the classes.  I have chosen to use a shared text box where
the grade classes display 
> their grades, and the user enters new grades.
> 
> John W. Colby
> www.ColbyConsulting.com 
> 
> 
> Michael Maddison wrote:
>> Hi John,
>>
>> Is the control bound?
>>
>> Cheers
>>
>> Michael M
>>
>> -----Original Message-----
>> From: dba-vb-bounces at databaseadvisors.com 
>> [mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of jwcolby
>> Sent: Tuesday, 29 September 2009 12:05 PM
>> To: VBA
>> Subject: [dba-VB] c# text box changed event
>>
>> I am setting the text in a text box via code which is causing the
TextChanged event to fire.  I want 
>> the event to fire for a manual edit so I can set a dirty flag, but not
for changing the data by 
>> code.  Is there a change event that fires for manual editing but not by
code editing?



 

__________ Information from ESET NOD32 Antivirus, version of virus signature
database 4468 (20090929) __________

The message was checked by ESET NOD32 Antivirus.

http://www.esetnod32.ru
 




More information about the dba-VB mailing list