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# / September 2005

Tip: Looking for answers? Try searching our database.

Textbox question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
CobraStrikes@al.com - 30 Sep 2005 12:34 GMT
Is there a easy way to stop a textbox receiving focus ? if so how ?
Morten Wennevik - 30 Sep 2005 15:00 GMT
Hi CobraStrikes,

You could use a Label, set BackgroundColor to the same as a TextBox and use a Fixed3D border.  This is probably the simplest.

You could also handle the Enter event of the TextBox and pass the focus on to the next control in the tab order

private void textBox1_Enter(object sender, System.EventArgs e)
{
    Control c = textBox1;

    // find the next control in the tab order until
    // we encounter one that can be selected
    do
        c = this.GetNextControl(c, true);
    while(!c.CanSelect && c != textBox1);
               
    c.Focus();
}

> Is there a easy way to stop a textbox receiving focus ? if so how ?

Signature

Happy coding!
Morten Wennevik [C# MVP]

Siva M - 30 Sep 2005 20:43 GMT
WinForms? If so, set the textbox TabStop property to false. However, user
can always click on the Text box to set the focus. Or, set Enabled property
to False.

Is there a easy way to stop a textbox receiving focus ? if so how ?

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.