Solved

TStringGrid event

Posted on 2000-05-11
4
412 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

630 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