Quantcast

Maximum PC

It is currently Wed Apr 23, 2014 10:19 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 27 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: Sat Apr 25, 2009 5:39 pm 
Little Foot
Little Foot

Joined: Sat Feb 11, 2006 11:04 am
Posts: 174
How do you make a text box read only?


Top
  Profile  
 
 Post subject:
PostPosted: Sat Apr 25, 2009 5:45 pm 
Million Club - 5 Plus*
Million Club - 5 Plus*
User avatar

Joined: Sun Sep 12, 2004 6:37 pm
Posts: 4740
Location: In the monkey's litterbox
xxmainframexpxx wrote:
How do you make a text box read only?


What language? There's a ReadOnly property on the Windows Forms textbox with .NET languages.


Top
  Profile  
 
 Post subject:
PostPosted: Sat Apr 25, 2009 5:52 pm 
Willamette
Willamette
User avatar

Joined: Fri Jul 06, 2007 9:29 am
Posts: 1447
Yep, depends on the language.

Like I've said, it's programming, so there's usually multiple ways of doing things. It all depends on the language, your needs, how creative you are, and how much work you want to do. :)

Off the top of my head:
1) Readonly flag if it is there. Sometimes this lets them type in the box though (it isn't saved, but it might not be what is desired)
2) Enabled flag (it'll still show the text, greyed out, but you can't type anything in it)
3) Keypress type events on the textbox (if any letters or numbers are typed in the box, ignore it)
4) OnExit type events on the textbox (reset value of the box back to the original value)
5) Keypress type events on the form (identify what box has focus, if it is the one in question, ignore the letters/numbers)

And so on. Different ways of doing it, each with their own pros and cons.


Top
  Profile  
 
 Post subject:
PostPosted: Sat Apr 25, 2009 7:21 pm 
Bitchin' Fast 3D Z8000
Bitchin' Fast 3D Z8000
User avatar

Joined: Mon Jun 14, 2004 4:04 pm
Posts: 985
Location: Earth
xxmainframexpxx wrote:
How do you make a text box read only?


I assume that because you started on C#, you're referring to .NET controls.

If so...
Code:
TextBox tb = new TextBox();
tb.ReadOnly = true;


This is mostly for ASP.NET but the same rules apply for TextBoxes in Windows applications. Good luck!


Top
  Profile  
 
 Post subject:
PostPosted: Sun Apr 26, 2009 7:57 am 
Little Foot
Little Foot

Joined: Sat Feb 11, 2006 11:04 am
Posts: 174
for C# my book says to add "&" in front of the letter that you want to make it a shortcut. But when i do that and run it i get an error. Im using visual C# 2008 by the way.


Top
  Profile  
 
 Post subject:
PostPosted: Sun Apr 26, 2009 9:23 am 
Little Foot
Little Foot
User avatar

Joined: Mon Jul 28, 2008 1:39 pm
Posts: 123
What do you mean "shortcut"? In C or C++ :
Code:
int x = 33;
int* ptrToX = &x;

&x returns the address of x in memory (used here to assign to a pointer).


Top
  Profile  
 
 Post subject:
PostPosted: Mon Apr 27, 2009 6:27 am 
Bitchin' Fast 3D Z8000
Bitchin' Fast 3D Z8000
User avatar

Joined: Mon Jun 14, 2004 4:04 pm
Posts: 985
Location: Earth
xxmainframexpxx wrote:
for C# my book says to add "&" in front of the letter that you want to make it a shortcut. But when i do that and run it i get an error. Im using visual C# 2008 by the way.


I think you're getting ahead of yourself.

When you add a menu in your winforms applications, you can specify a shortcut by adding the & to the text itself ( menuItem.Text = "&File") and that will show up as a shortcut. So when you press ALT+F, it opens up that shortcut.

What exactly are you trying to accomplish and are you following a set curriculum?


Top
  Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 27 posts ]  Go to page Previous  1, 2

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group