Selecting the text within a TStringGrid cell - user-interface

The component I use is a descendant of TStringGrid, called TDataGrid (which can be found on Torry). Unfortunately, it has a small bug which doesn't seem to be present in the original TStringGrid component. I have the options goEditing and goAlwaysShowEditor both enabled, so I'm expecting the text of a cell to be selected when the control receives input focus. But in the case of TDataGrid this doesn't happen if I press TAB to move from one control into the grid control. It receives input focus, but nothing is selected, and the caret isn't even visible. Obviously, this is very misleading for a user.
The original TStringGrid component has similar inconsistencies, where if you have goAlwaysShowEditor enabled, there is always one cell with its text "exposed" (focused, sort of, even if the grid control itself doesn't have focus), so if you left-click in that cell, it also won't select the text, just enable a caret. I have been able to get around this however, by simply disabling goAlwaysShowEditor when the grid control doesn't have focus and subsequently enabling it when the grid receives focus.
So does a TStringGrid have any way of selecting the text of a cell? I know how to set the focus to a cell, but I haven't figured out a way to actually select the text. Really would appreciate any ideas to get around this!
FWIW, I'm using Delphi 10.3

I've found one solution that actually seems to work, but it only handles the very specific scenario when you TAB into the grid control and there may be other cases that need to be handled..
So, controlling the selection of the text within a cell IS possible, but it will not work if you try to control it during the OnEnter event. So instead, I've had to resort to checking for TAB in the OnKeyUp event, where it will work.
You need to expose protected members of a TStringGrid to access the appropriate methods. It's not the prettiest solution, but it works at least...
type TStringGridHelper = class helper for TStringGrid
procedure HHideEditor;
procedure HShowEditor;
end;
procedure TDataGridHelper.HHideEditor;
begin
HideEditor;
end;
procedure TDataGridHelper.HShowEditor;
begin
ShowEditor;
end;
And in the OnKeyUp event handler...
if Key = VK_TAB then begin
StringGrid.HHideEditor;
StringGrid.HShowEditor;
end;

Related

GWT - Handler for lost focus on widgets in flextable

I'm currently coding in GWT, for the first time, and it's going well so far. I'm having a problem with EventHandlers though. I have a FlexTable which has 2 columns, 1 for labels, and 1 for TextBox/ListBox fields. When a user insert datas into the textbox and leaves the textBox again, I want to write the contents to an object. That is quite easy, But, I can't figure out how to make the ActionHandler for it? It works fine with an OnClick event, but I want something like on focus from the FocusListener, but it's deprecated...! So what I need in a GWT, onLostFocus EventHandler of some type.
Add a BlurHandler over the TextBox. It gets called when the TextBox will lose the focus.
You can also try with valueChangeHandler on TextBox and ListBox too. Another way , you can use DomHandler on your parent widget.

Is there an event that is fired when HoT puts a cell into edit mode?

I'd like to alter a cell's data, but only when it enters "edit" mode. There are a lot of events I can use, onSelectionByProp seems close but it's firing too often to be useful. Let's say, for instance, that I want to add '*' to a cell that has a value that is invalid in some way, but only when that cell is about to be edited. OK, it's a silly example but it's easier to explain that than what I'm actually doing.
My current approach (haven't done it yet) is to find TD.current when a cell is double-clicked and then alter the text directly. Ideally I'd like to find a "retrieve data" event and alter what's coming back from that.
You can map keyup, keydown, keypress or change event from jQuery for .handsontableInputHolder element in a page. Is a textarea in which user enter data, so this is your 'edit mode' for handsontable.
onEditBegin is a proposed event for future version.
See here for list of events

Simple Oracle Forms Menu

I wan't to have a simple menu (main menu not menu bar) whith buttons to link to another form(s)/window(s)/caveses(s). Or atleast the code to switch bettween the screen.
What code (SQL/PL) would I put in the buttons or is there a better way to do this?
That's a very broad question. If you want to show a specific window on WHEN-BUTTON-PRESSED then you can use built in like below-
SET_WINDOW_PROPERTY('WINDOW_NAME', VISIBLE, PROPERTY_TRUE); --This would display the window
SET_WINDOW_PROPERTY('WINDOW_NAME', VISIBLE, PROPERTY_FALSE); --This will hide the window
The above would work if you use the SET_WINDOW_PROPERTY within the same form.
In case you want to call another form from the parent form (which is the case as per your comment screenshot) you need to to use CALL_FORM built-in like
CALL_FORM('MEMBERS');
Why dont you just make 1 form only?1 form, many datablock,canvas, window
anyway, for your question, just call the block
go_block('your_block');
if you want to call another block
go_block('another_block');
hide_window('1st_open_window');
you should make 1 canvas in 1 window for better arrangement
You can also use Stack canvas within the same form which gets visible as you click on the button.
SHOW_VIEW('CANVAS_NAME');
And in that stack you can do whatever you want.

Windows Vista and 7 motion effects are applied only once when my form is shown. Why?

I created an application with two forms. First one is the main form and second one is hidden.
I placed a button on Form1 and I made it ShowModal the second form. On Win7 the form appears with an animation. Then I close the appeared form (Form2) and I click the button once again. Form2 appears without the animation. I want the animation every time. What should I do?
The only thing I can think of right now is to create the form manually each time you want to display it modally. To do this, go to the project options and make sure that the form isn't automatically created. Then do
procedure TForm1.Button1Click(Sender: TObject);
begin
with TForm2.Create(self) do
try
ShowModal;
finally
Free;
end;
end;
In my opinion, most often modal forms should in fact be created manually.
Well, you could just elect not to worry about it! Alternatively a very quick hack would be to free the form each time it closes since the animation appears to run only on the first time the form is shown.
EDIT: Another approach would be to call DestroyHandle on your form whenever it closes. I'm guessing now, but I imagine that Windows records somewhere in the window a flag indicating that the animation has been shown. Once this flag has been set the animation is never shown again.
As an alternative way it's possible to fool windows by sending a notification that form's style has been changed, that will make windows reset "secret flag" for current form's handle. Thus, on showing already created form the cool show effect animation will be applied again. However, I can't say what negative effects can be caused by doing this way.
uses
Winapi.Windows, Vcl.Controls;
type
TFormHelper = class helper for TForm
public
procedure Show;
end;
implementation
procedure TFormHelper.Show;
begin
SendMessage(Handle,CM_CUSTOMSTYLECHANGED,0,0);
inherited Show;
end;
Note: code featured with a class helper, this feature/keyword might be not available in older IDEs.

Janus GridEX Problem

It's a longshot that anyone can help with this, but here goes. I inherited a VB6 app with a Janus GridEX control. It iterates through records, and is editable. Problem is, if I edit a cell and hit the button to go to the next record, the change is applied to the next record, not the one I was editing. It's like, I need it to finish up the edit before going to the next record. I've had this sort of problem before in VC++, and sometimes you have to "KillFocus" on the control you're on or something. I just don't know what to do here. I tried sending a carriage return, since if you return out of the edit cell, it works, but sending a carriage return manually doesn't work. What's the secret?
Is your grid bound or unbound?
It's hard to tell from your description, but I imagine that if your are having this problem then it's probably bound.
As the other answer asked, is the button the RecordNavigator that is built into the control or is it a separate button? The reason I bring this up again, is that I have seen issues in the VB6 applications I support where a toolbar will often intercept and interfere with how the JanusGrid should work.
To get around this limitation, I have added the following code in the click handler of any toolbars where there is also a JanusGrid control on the form.
If jsgxYourGridName.EditMode = jgexEditModeOn Then jsgxYourGridName.Update
This way any changes are immediately applied to the current row.
If this does not help, then I have also seen problems where the recordset that is bound to the grid gets out of sync with the internal recordset in the grid. You can check this by comparing the bookmark of the grid to the bookmark of the recordset.
Ie. mrsYourRecordset.Bookmark = jsgxYourGrid.ADORecordset.Bookmark
At one point I may have also used something like this.
jsgxYourGrid.ADORecordset.Bookmark = jsgxYourGrid.RowBookmark(jsgxYourGrid.RowIndex(jsgxYourGrid.Row))
Finally you can try setting a breakpoint in the BeforeUpdate, RowColChange and/or AfterColUpdate events of the grid, to see what record the grid is really on when clicking on the button.
It depends whether the button is internal to Janus GridEX or not. If it internal then just about the only thing you can do is look at the events the control exposes to see if there a sequence that can let you know that this problem occurs. Then you can try to take corrective action by restoring the row you moved to and put the edit in the row you left.
If the button is external to Janus then you can use the debug mode to trace sequence of statement that control the transfer of focus to the next row. It could be something out of order or a side effect of the particular sequence of commands. I have run into both with different controls.
Remember that you can edit while in debug mode so you can try different approaches and test until you find one that works.

Resources