Преобразовать первую букву каждого слова к верхнему регистру в TEdit |
Previous Top Next |
Code: |
procedure TForm1.Edit1Change(Sender: TObject); var OldChange: TNotifyEvent; OldStart: Integer; begin with (Sender as TEdit) do begin OldChange := OnChange; OnChange := nil; OldStart := SelStart; if ((SelStart > 0) and (Text[SelStart - 1] = ' ')) or (SelStart = 1) then begin SelStart := SelStart - 1; SelLength := 1; SelText := AnsiUpperCase(SelText); end;
OnChange := OldChange; SelStart := OldStart; end; end; |
©Drkb::00975
Взято с сайта: http://www.swissdelphicenter.ch
Code: |
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); begin with Sender as TEdit do if (Text = '') or (Text[SelStart] = ' ') or (SelLength = Length(Text)) then if Key in ['a'..'z'] then Key := UpCase(Key); end; |
©Drkb::00977
DelphiWorld 6.0