Solved

TStringGrid event

Posted on 2000-05-11
4
406 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now