Recent

Author Topic: [Solved] Unexpected behavior of DBRadioGroup !  (Read 782 times)

loaded

  • Hero Member
  • *****
  • Posts: 825
[Solved] Unexpected behavior of DBRadioGroup !
« on: January 19, 2021, 01:24:02 pm »
Hi All,
I am using DBRadioGroup to control a 2-state field in my application.
When the program is first opened, there is no problem, but if I click on any datacontrol except DBRadioGroup, DBRadioGroup will reset itself.
Then, if I manually click DBRadioGroup a few times, the problem goes away.
I don't know if I am making a mistake or if this is a problem.
Do you think it could be the cause, and how can it be fixed?
I would really appreciate if you can help.
« Last Edit: January 20, 2021, 09:25:32 am by loaded »
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: Unexpected behavior of DBRadioGroup !
« Reply #1 on: January 19, 2021, 03:20:45 pm »
You should post a small demo which shows the issue (pack .pas, .lfm, .lpi, .lpr and database file into a common zip which you can upload via "Attachments and other options"). Write the demo such that it works with a simple dataset, such as TBufdataset, TDBF or sqlite3 -- nobody is willing to install an exotic database engine just to verify an issue of a visual db-control.

loaded

  • Hero Member
  • *****
  • Posts: 825
Re: Unexpected behavior of DBRadioGroup !
« Reply #2 on: January 19, 2021, 05:03:58 pm »
wp, thank you very much for the answer.
While doing an application work to send to form;
I noticed that the
Code: Pascal  [Select][+][-]
  1. procedure TForm1.DBGridOnGetText(Sender: TField; var aText: string; DisplayText: Boolean);
  2. begin
  3.   if  (DisplayText) then  aText := Sender.AsString;
  4. end;
  5. procedure TForm1.DBGrid1PrepareCanvas(sender: TObject; DataCol: Integer;Column: TColumn; AState: TGridDrawState);
  6. var
  7.   MyTextStyle: TTextStyle;
  8. begin
  9.     MyTextStyle := TDBGrid(Sender).Canvas.TextStyle;
  10.     MyTextStyle.SingleLine := False;
  11.     MyTextStyle.Wordbreak  := False;
  12.     TDBGrid(Sender).Canvas.TextStyle := MyTextStyle;
  13.     Column.Field.OnGetText := @Form1.DBGridOnGetText;
  14. end;
  15.  

codes I used to display (MEMO) fields as text on the dbgrid caused unexpected behavior on the DBRadioGroup.
Then I looked for an alternative solution to this.

Located in the https://stackoverflow.com/questions/4809298/lazarus-dbgrid-showing-memo-as-the-value-of-string-fields-in-sqlite-3 link;
I learned that the
Quote
Setting the dgDisplayMemoText property of dbgrid to true
recommendation is simpler and smoother.
When I applied it, my problem was solved.
« Last Edit: January 20, 2021, 09:25:18 am by loaded »
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

 

TinyPortal © 2005-2018