Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cursor position in TValueListEditor

Status
Not open for further replies.

aik2

Programmer
Jun 10, 2003
21
Hello all !

Does anybody know how to manage a cursor position in the cell of the TValueListEditor ?
And maybe anybody know how to make a highlight of the current cell ?

Thanks in advance,
Ilya
 
To highlight the current cell, set goDrawFocusSelected to true in the Options property of the TValueListEditor.
I'm not sure how best to control the cursor position in a cell, you could try using WM_KEYDOWN messages, e.g.

Code:
  SendMessage(edit,WM_KEYDOWN,VK_END,0);

Steve
 
The problem, that when I'm moving by arrows, cell is selected, but I want move to next cell by Enter key and that's the case when cell is not selected and cursor stays at end of cell.

SendMessage didn't help :(

Ilya
 
In that case try using the KeyDown event, this example will move you on to the next column when the user presses the return (i.e. enter) key

Code:
procedure TForm1.ValueListEditor1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  if Key = VK_RETURN then
    ValueListEditor1.Col := ValueListEditor1.Col + 1;
end;

Steve
 
I do exactly like this, but cursor stays at the end of text in the cell and this cell is not highlighted
 
There is a problem in using the return key to do what you want, because the return key is used to enable the user to edit the values in the cells. This is why the cell is not highlighted and the cursor is shown in the cell, because pressing the return key switches on editing!
You could prevent the return key from switching editing on/off like this:

Code:
procedure TForm1.ValueListEditor1KeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then
    Key := #0;
end;

but then the user would have no way of being able to edit the values in the cells!
I don't think there's really any way around this, unless you create your own component inherited from TValueListEditor, in which case you will have access to the ShowEditor and HideEditor methods (these are protected methods of TCustomGrid). That wouldn't be too hard, but it's a case of how confident you are creating your own components and how much effort you want to put in!

Steve
 
You could off course do something with a checkbox to enable
editing:

Code:
procedure TForm1.ValueListEditor1KeyPress(Sender: TObject; var Key: Char);
begin
if not chbEnableEditing.Checked then
   if Key = #13 then
      Key := #0;
end;

[bobafett] BobbaFet [bobafett]
Code:
if not Programming = 'Severe Migraine' then
                       ShowMessage('Eureka!');
 
Thank you ! Code for KeyPress is helps!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top