Поддержка / Donate
 

WebMoney

Яндекс.Деньги

SMS.Копилка
Деньги@Mail.ru
Rupay
E-gold
PayPal

 

Благодарю за поддержку!

Лента RSS - Новости сайта Новости сайта
Лента RSS - Новости форума Новости форума
Добавить в закладки и поделиться Bookmark and Share

 

Архив исходников

 


Automatic translation

 
English German French
Italian Spanish Portuguese
Greece Japan Chinese
  Korean  

  

 

  Форум  

Delphi FAQ - Часто задаваемые вопросы

| Базы данных | Графика и Игры | Интернет и Сети | Компоненты и Классы | Мультимедиа |
| ОС и Железо | Программа и Интерфейс | Рабочий стол | Синтаксис | Технологии | Файловая система |



Google  
 

Позиционирование каретки в TStringGrid

Оформил: DeeCo
Автор: http://www.swissdelphicenter.ch

{ 
  The following code allows you to position the caret 
  in a cell (InplaceEditor) of a StringGrid. 
  We need a Cracker class to access the InplaceEditor. 

  Mit folgendem Code kann man den Cursor in einer Zelle 
  (InplaceEditor) eines StringGrids positionieren. 
  Hierfur brauchen wir eine "Cracker" Klasse, weil der 
  InplaceEditor "protected" ist. 
}

 type
   TGridCracker = class(TStringGrid);

    {...}

 implementation

 {...}

 procedure SetCaretPosition(Grid: TStringGrid; col, row, x_pos: Integer);
 begin
   Grid.Col := Col;
   Grid.Row := Row;
   with TGridCracker(Grid) do
     InplaceEditor.SelStart := x_pos;
 end;

 // Get the Caret position from the focussed cell 
// Ermittelt die Caret-Position der aktuellen Zelle 
function GetCaretPosition(Grid: TStringGrid): Integer;
 begin
   with TGridCracker(Grid) do
     Result := InplaceEditor.SelStart;
 end;

 // Example / Beispiel: 

// Set the focus on col 1, row 3 and position the caret at position 5 
// Fokusiert die Zelle(1,3) und setzt den Cursor auf Position 5 

procedure TForm1.Button1Click(Sender: TObject);
 begin
   StringGrid1.SetFocus;
   SetCaretPosition(StringGrid1, 1, 3, 5);
 end;



Источник - Проект "Delphi World" © Выпуск 2002 - 2004
Автор проекта: Акулов Николай



   Rambler's Top100             Яндекс цитирования