Board index » delphi » TStringGrid.OnExit and TButton.OnClick

TStringGrid.OnExit and TButton.OnClick

Hi,

I have a form with a  TStringGrid, having an OnExit event handler, and
several buttons. The problem is that I must click a button twice, in
order to activate the button OnClick event handler. First time I click a
button the TSringGrid.OnExit is executed. Until here it's OK, but than I
must click the button again. What I want is that on a single click to be
executed the TStringGrid.OnExit and the TButton.OnClick. Is this
possible?
How can I know wich button was clicked?

Please, help me.
Thanks,

Csilla

 

Re:TStringGrid.OnExit and TButton.OnClick


Csilla,
  in message <3A56DF8A.E82E...@cluj.ambo.ro> you wrote:

Quote
> I have a form with a  TStringGrid, having an OnExit event handler, and
> several buttons. The problem is that I must click a button twice, in
> order to activate the button OnClick event handler. First time I click a
> button the TSringGrid.OnExit is executed. Until here it's OK, but than I
> must click the button again. What I want is that on a single click to be
> executed the TStringGrid.OnExit and the TButton.OnClick. Is this
> possible?

That shouldn't be the case.

Can you show us the code from the StringGrid exit handler? If it's less than
approx 100 lines, post it here. If more post it to borland.public.attachments
with a post here stating that it's in attachments.

--
Regards
Ralph (TeamB)
===

Re:TStringGrid.OnExit and TButton.OnClick


Quote
"Ralph Friedman (TeamB)" wrote:
> Csilla,
>   in message <3A56DF8A.E82E...@cluj.ambo.ro> you wrote:
> > I have a form with a  TStringGrid, having an OnExit event handler, and
> > several buttons. The problem is that I must click a button twice, in
> > order to activate the button OnClick event handler. First time I click a
> > button the TSringGrid.OnExit is executed. Until here it's OK, but than I
> > must click the button again. What I want is that on a single click to be
> > executed the TStringGrid.OnExit and the TButton.OnClick. Is this
> > possible?

> That shouldn't be the case.

> Can you show us the code from the StringGrid exit handler? If it's less than
> approx 100 lines, post it here. If more post it to borland.public.attachments
> with a post here stating that it's in attachments.

> --
> Regards
> Ralph (TeamB)
> ===

Sorry, my mistake. It's more complicated. So, in the StringGrid I have an
RxSpinEdit. This edit has an OnExit event and not the StringGrid.

Re:TStringGrid.OnExit and TButton.OnClick


Csilla,
  in message <3A572084.71B5C...@cluj.ambo.ro> you wrote:

Quote
> Sorry, my mistake. It's more complicated. So, in the StringGrid I have an
> RxSpinEdit. This edit has an OnExit event and not the StringGrid.

we would still need to see your code in order to recommend something. The code
used to insert the spinEdit into the StringGrid would be interesting also.

--
Regards
Ralph (TeamB)
===

Re:TStringGrid.OnExit and TButton.OnClick


Quote
"Ralph Friedman (TeamB)" wrote:
> Csilla,
>   in message <3A572084.71B5C...@cluj.ambo.ro> you wrote:
> > Sorry, my mistake. It's more complicated. So, in the StringGrid I have an
> > RxSpinEdit. This edit has an OnExit event and not the StringGrid.

> we would still need to see your code in order to recommend something. The code
> used to insert the spinEdit into the StringGrid would be interesting also.

> --
> Regards
> Ralph (TeamB)
> ===

The edit is inserted in the grid when enabling a Timer.

procedure TdlgRun.tmrSelectTimer(Sender: TObject);

//this  will place the control in the grid
  procedure PlaceControl(var p_tc: TCustomEdit; p_parent: TWinControl);
  var
    r    : TRect;
  begin
    r := grdMatrix.CellRect(m_nCurCol, m_nCurRow);

    p_tc.Visible := FALSE;
    p_tc.Parent  := p_parent;

    p_tc.Top     := r.Top  + 3 * grdMatrix.GridLineWidth;
    p_tc.Left    := r.Left + 3 * grdMatrix.GridLineWidth;
    p_tc.Width   := r.Right - r.Left + grdMatrix.GridLineWidth - 1;

    p_tc.Visible := TRUE;
  end;

begin
  tmrSelect.Enabled := False;

  TRY
    m_ciCur := MtxColInfoByIdx(m_nCurCol, m_nCurRow);

    IF m_ciCur.Editable then begin
      IF (m_ciCur.strType = g_ctString) THEN BEGIN

        // bring to front the string editing field
        PlaceControl(TCustomEdit(edMtxStr), pnlGrid);
      END ELSE BEGIN
        IF ((m_ciCur.strType = g_ctNumber) or
            (m_ciCur.strType = g_ctPercent)) THEN BEGIN

         // bring to front the number editing field
          PlaceControl(TCustomEdit(edMtxNbr), pnlGrid);
        END;
      END;
    END;
  EXCEPT
 END;
end;

procedure TdlgRun.edMtxNbrExit(Sender: TObject);
begin
  ActiveControl    := grdMatrix;
  actSaveNbrCell.Execute;
end;

procedure TdlgRun.actSaveNbrCellExecute(Sender: TObject);
begin
    ActiveControl    := grdMatrix;
    FormatFloat('#.##', edMtxNbr.Value);
    m_ciCur.strValue := FloatToStr(edMtxNbr.Value);
    grdMatrix.Cells[grdMatrix.Col, grdMatrix.Row] := m_ciCur.strValue;

    IF (m_ciCur.strType = g_ctPercent) THEN BEGIN
    PopulateChart(m_ciCur.ColIdx);
    END;
end;

Re:TStringGrid.OnExit and TButton.OnClick


Csilla,
you wrote  in message <3A57349C.93231...@cluj.ambo.ro>:

Quote
> ActiveControl    := grdMatrix;

The above is your problem. You are, in effect, explicitly returning to the grid
in the OnExit from the SpinEdit. Thus interfering with the chain of events set
in motion by clicking on the TButton.

--
Regards
Ralph (TeamB)
===

Re:TStringGrid.OnExit and TButton.OnClick


Quote
"Ralph Friedman (TeamB)" wrote:
> The above is your problem. You are, in effect, explicitly returning to the grid
> in the OnExit from the SpinEdit. Thus interfering with the chain of events set
> in motion by clicking on the TButton.

Thank you. It's OK now.

Csilla,

Other Threads