Solved

TStringGrid event

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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 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.

752 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