Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / August 2007

Tip: Looking for answers? Try searching our database.

text change question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jassim Rahma - 10 Aug 2007 23:44 GMT
i have two textboxes.

txtHostName and txtHotTitle

when the user types in the txtHostName it automatically set the txtHostTitle
= txtHostName

until now it's ok..

now, i want if the user changed the value in txtHostTitle using the keyboard
or the mouse shortcuts (delete, cut, etc) which means i f the use chaned the
value in txtHostTitle in anyway then it should not update the txtHostTitle =
txtHostName

I have created a variable called host_titel_changed which is initially false
but i want to know how can i make it true when detecting any changes in the
txtHostTitle
Morten Wennevik - 11 Aug 2007 09:43 GMT
> i have two textboxes.
>
[quoted text clipped - 13 lines]
> but i want to know how can i make it true when detecting any changes in the
> txtHostTitle

Hi Jassim,

You can do this with DataBinding,

Have txtHostName bind to a property, for instance "Name";
Have txtHostTitle bind to another property, for instance "Title";
In Title's getter, check your flag, if set, read it's own value, otherwise, read Name

private string _name;
public string Name
{
    get{ return _Name; }
    set{ _name = value; }
}

private string _title;
bool host_title_changed;
public string Title
{
    get
    {
        if(host_title_changed)
            return _title;
        else

            return Name;
    }
    set
    {
        _title = value;
        host_title_changed = true;
    }
}

Signature

Happy coding!
Morten Wennevik [C# MVP]


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.