Forum > LCL

[SOLVED] like TRadioGroup but with individual Hints + all Buttons checkoff-able

(1/2) > >>

Hartmut:
I'm searching for something like 'TRadioGroup', but with individual ToolTips for each RadioButton and all RadioButtons must be setable to 'off' (at the same time) programmatically.

I tried Event TRadioGroup.OnShowHint but this seems not to be fired at all (maybe this is the reason why it's not offered in the ObjectInspector).

I tried a combination of 1 TRadioGroup and some TRadioButtons, which allowes individual ToolTips, but I did not manage to set all RadioButtons to 'unchecked' at the same time (via code).

Same result with a combination of 1 TGroupBox and some TRadioButtons.

I'm on Linux Ubuntu 22.04 64-bit with Lazarus 2.0.10 / FPC 320.

Any idea for a workaround? Thanks in advance.

wp:
The TRadioGroup has a public array property Buttons exposing the RadioButtons contained in the group. You can use this to define individual hints by code:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.FormCreate(Sender: TObject);begin  RadioGroup1.Buttons[0].Hint := 'Item 1';  RadioGroup1.Buttons[1].Hint := 'Item 2';  RadioGroup1.Buttons[2].Hint := 'Item 3';end;

jamie:
Buttons are in the Trunk , not release it appears.

And also, you can set them all blank if you set the ItemIndex := -1

The control does have a OnShowHint event but its not published, at least not on the release.

wp:
I see...

For release, a little hacky (assuming that no other controls have been added to the TRadioGroup):

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.FormCreate(Sender: TObject);begin  RadioGroup1.Controls[0].Hint := 'Item 1';  RadioGroup1.Controls[1].Hint := 'Item 2';  RadioGroup1.Controls[2].Hint := 'Item 3';end;

ASerge:

--- Quote from: Hartmut on June 02, 2024, 06:54:05 pm ---I'm searching for something like 'TRadioGroup', but with individual ToolTips for each RadioButton and all RadioButtons must be setable to 'off' (at the same time) programmatically.

--- End quote ---

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.btnAllOffClick(Sender: TObject);begin  RadioGroup1.ItemIndex := -1;end; procedure TForm1.FormCreate(Sender: TObject);var  i: SizeInt;  C: TControl;begin  RadioGroup1.Items.Text := 'Item 1' + LineEnding + 'Item 3' + LineEnding + 'Item 3';  RadioGroup1.ShowHint := True;  for C in RadioGroup1.GetEnumeratorControls do    C.Hint := 'Hint for ' + C.Caption;end;

Navigation

[0] Message Index

[#] Next page

Go to full version