Articles   Members Online: 3
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to make the first letter of a user-entered word in a TComboBox always upperc Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
27-Aug-02
Category
VCL-General
Language
Delphi All Versions
Views
60
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

Does anyone have a routine for uppercasing only the first letter of each word the 
user typed in an edit control - especially a combo box. I've experimented with the 
mask property for the dataset field but am not having any luck.

Answer:
1   
2   procedure TForm1.ComboBox1Change(Sender: TObject);
3   var
4     s, TempString: string;
5     Cnt, temp: integer;
6   begin
7     s := ComboBox1.Text;
8     temp := ComboBox1.SelStart;
9     if s <> '' then
10    begin
11      for Cnt := 1 to Length(s) do
12      begin
13        if (Cnt = 1) or (s[Cnt - 1] in [' ', ', ', ' ;']) then {or others here}
14        begin
15          TempString := s[Cnt];
16          s[Cnt] := AnsiUpperCase(TempString)[1];
17        end;
18      end;
19      ComboBox1.Text := s;
20    end;
21    ComboBox1.SelStart := temp;
22  end;


I strongly recommend to use the AnsiUpperCase function, if there's any possibility that non-English words may ever be entered into your application.

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC