Solved

TStringGrid event

Posted on 2000-05-11
4
408 Views
Last Modified: 2008-02-26
Does anyone know how to make the focused item on a TStringGrid move, say one item down, when the user changes it's value? /like in MS Excel worksheet/
...perhaps onChange event would do the job, but it's not implemented in TStringGrid....
..any ideas?
TL
0
Comment
Question by:TL010600
  • 2
  • 2
4 Comments
 
LVL 1

Expert Comment

by:jbodom
ID: 2801235
In Excel, you still have to tab or arrow to the next item.  TStringGrid supports this as part of the Options properties goEditing and goTabs
0
 

Author Comment

by:TL010600
ID: 2803851
Ya, but in Excel u dont have to navigate with the down key /by default/ to move to the next down position -> when a field is JUST edited the focused one is automaticaly moved down by one position...thats what I intend to do in C++ Builder....
0
 
LVL 1

Accepted Solution

by:
jbodom earned 100 total points
ID: 2804925
I'm guessing you're talking about after you hit the enter key.  If so, the following should help get you started.  Place this code in the TStringGrid KeyPress event handler:

void __fastcall TForm1::StringGrid1KeyPress(TObject *Sender, char &Key)
{
  if (StringGrid1->EditorMode && Key == VK_RETURN){
    if (StringGrid1->Row < StringGrid1->RowCount - 1)
      StringGrid1->Row = StringGrid1->Row + 1;
    else{
      if(StringGrid1->Col<StringGrid1->ColCount-1){
        StringGrid1->Row = StringGrid1->FixedRows;
        StringGrid1->Col = StringGrid1->Col + 1;
      }
      else{
        StringGrid1->Row=StringGrid1->FixedRows;
        StringGrid1->Col=StringGrid1->FixedCols;
      }
    }
  }
}
0
 

Author Comment

by:TL010600
ID: 2805326
ThanX! It seems to work!
..... thought the grid remains in edit mode, but I think I'll fix it! :)
TL
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question