BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Suggestion required for ensuring that a given row in one TSt

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
Ted Byers
Guest





PostPosted: Mon Nov 24, 2003 3:51 pm    Post subject: Suggestion required for ensuring that a given row in one TSt Reply with quote



OK, on one form, I have two TStringGrids. The top row one each has the
names of objects that must be the same in the two grids, but at the same
time must be user editable. I am looking for suggestions as to how best to
do this. I can see several options.

The more tedious one involves catching all key press events and all events
that could be involved in selecting text, and if the first row of the grid
is the current one, duplicate the effect on the first row of the second,
whether that is to append a character to the current text, delete the last
character or overtype the selected text. I can see that getting rather
complex rather quickly.

A second option I considered is, if the current row it the first, send all
key press events received by each grid to the other. The problem there is
how to ensure that we don't get a stack overflow produced by each event
handler calling the other.

It occured to me that in an OnChange event for each grid, check to see if
the first row is the current row and if so set the appropriate text in the
other grid to that in the current grid, but there is no OnChange event in
TStringGrid.

Another option would be to do much the same thing except that one traps when
the user moves from one cell to another on a given grid, regardless of how
that is done (i.e. regardless of whether the user has used tab or an arrow
key ot the mouse). If that can be done, then if the current cell is in the
first row in the current grid , and the user moves to another cell,
regardless of where that cell is, set the appropriate text in the other grid
to the text that is in the cell that was just left because of user action.
I wonder if OnSelectCell would do the trick? Does it occur in response to
keypress events as well as mouse events? Does it occur before or after the
row identified in Grid->Row is set to its new value?

The over-riding criterion here is simplicity, especially for the sake of
minimizing the probability of bugs. It also needs to be done in a way that
won't confuse the user. I haven't decided yet whether the unusual behaviour
I am looking to implement is going to be confusing and whether or not it is
necessary to prevent the user from making an agregious error (aiming to
ensure the data is always correct given the data model required for this
application).

Any thoughts?

Cheers,

Ted


Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Mon Nov 24, 2003 6:20 pm    Post subject: Re: Suggestion required for ensuring that a given row in one Reply with quote




"Ted Byers" <r.ted.byers (AT) sympatico (DOT) ca> wrote

Quote:
OK, on one form, I have two TStringGrids. The top row one each has
the names of objects that must be the same in the two grids, but at the
same time must be user editable. I am looking for suggestions as to how
best to do this.

When the user edits a cell, the OnSetEditText event will be triggered. The
parameters of the event handler include the Column and Row indexes of the
modified cell as well as the new value itself. With those three pieces of
data, you can update the other grid as needed.

Quote:
A second option I considered is, if the current row it the first, send
all key press events received by each grid to the other. The problem
there is how to ensure that we don't get a stack overflow produced
by each event handler calling the other.

By using a flag for each grid (maybe as simple as just using the Tag
property). You set the flag before forwarding the event to the other grid
and then reset the flag afterwards. That way, each grid can know whether an
event is being triggered as a result of the other grid and not the user if
the flag is set, and if so then the event handler can choose not to call
back into the other grid again.


Gambit



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.