How to assign a radiogroup line to a Editbox.text - delphi

I am trying to use the lines or text next to the radiogroup's radiobuttons to be assigned to the text of a editbox or any other type of output please :) I am using Delphi 2010

The Items property contains the radio button captions, and the ItemIndex property contains the index of the radio button that is currently selected. For example:
procedure TForm1.RadioGroup1Click(Sender: TObject);
begin
Edit1.Text := RadioGroup1.Items[RadioGroup1.ItemIndex];
end;

Related

Delphi TComboBox disable highlight (focused)

After open form item in TCombobox is highlighted (Blue backgrond on text).
Is it possible disable that.
Tnx all!
You can put this message into OnEnter event of TCombobox object:
// Suppose the combobox control name is ComboBox
procedure TMainForm.ComboBoxEnter(Sender: TObject);
begin
PostMessage(ComboBox.Handle, CB_SETEDITSEL, Cardinal(-1), 0);
end;

Delphi: Bind a Chart with a DBGrid

I want to bind a Chart with a DBGrid.
Refer to the exhibit.
When I click in the DBGrid on number 3 (X-Axis), then the bar at position three should be highlighted(or a pointer to bar 3).
When I click on number 4 in the Grid then bar 4 is highlighted etc.
I'm using a TDBChart
Is there a way to do this?
Not knowing what the charting component is, cannot provide a working example, but the key which you are looking for is to use the AfterScroll event for the dataset in the grid. Since each row represents a different record, that event is fired when the grid selection moves to the row.
Edit: This doesn't highlight with a box, but does change the color of the value marks at the top of each bar. Hopefully this gets you on your way. MyQuery is what is feeding the datasource
var
savecolor : tcolor;
procedure MyForm.FormShow(Sender:TObject);
begin
...
SaveColor := dbchart1.series[0].marks.items[0].color;
...
end;
procedure MyForm.MyQueryBeforeScroll(DataSet : TDataSet);
begin
dbchart1.series[0].marks.items[MyQuery.recno-1].color := SaveColor;
end;
procedure MyForm.MyQueryAfterScroll(DataSet:TDataSet);
begin
dbchart1.series[0].marks.items[MyQuery.recno-1].color := clRed;
end;

Delphi - How to copy the text from one tedit to another, while the user is typing in the first one?

There are two tedit
One is enabled for the user, and the other disabled.
The moment user types anything in the tedit, the same thing gets typed in the disabled tedit, while the user is typing.
I don't want to use any buttons for this.
How to implement this in Delphi?
You can use the OnChange event of your first TEdit and set text of the second edit to the text of the first. This should look like
procedure TForm1.Edit1Change(Sender: TObject);
begin
Edit2.Text := Edit1.Text;
end;

get categorybuttons items caption under mouse in delphi

how can I get caption of an item or a category when mouse is entering on them?
how can I get the current caption of an item or a category when right clicking on them?
I assigned a popup menu to categorybuttons. Now I need to obtain the current item or category captions and save them in variable. Because my popup menu has an item that by clicking on it it opens a new form so I want to use this variables values here.
Something like this works at click event :
Current_Items, Current_Category: String
procedure TForm1.CategoryButtons1Click(Sender: TObject);
begin
Current_Items := CategoryButtons1.CurrentCategory.Items
[CategoryButtons1.SelectedItem.Index].Caption;
Current_Category := CategoryButtons1.CurrentCategory.Caption;
end;
But I need to obtain them when right click.
Can someone helps me to do this?
Thank you...
Edit:
Use the OnHotButton event to prepare the Current_Item variable. That gives you the Item on which the mouse right button is clicked, but not the category.
Just note however that this does not select (activate) that particular button.
var
Current_Items, Current_Category: String;
procedure TForm17.CategoryButtons1HotButton(Sender: TObject;
const Button: TButtonItem);
begin
if Button <> nil then
Current_Items := Button.Caption;
end;
Then use Current_Items to identify which button is hot when you popup the menu.

Delphi, Show button in a different TGridPanelLayout cell

Hi I am working with XE6 and I am using a TGridPanelLayout with 4 col and 4 rows. On the first cell I am displaying a Button. What I would like to do is, that when I click on this Button, get that Button to appear in a different cell. But I cannot find how to do it, so far I tried this, but nothing happens.
procedure TForm4.Button1Click(Sender: TObject);
begin
GridMyPannel.ControlCollection.BeginUpdate;
GridMyPannel.ControlCollection.AddControl(Button1, 2, 2);
Button1.Parent := GridMyPannel;
end;
I am really new on Delphi. Could anyone give me an example of how I could do it?
A TGridPanel has a ControlCollection property which allows access to the Row and Column properties that also appear on your TButton once you've placed in inside your TGridpanel. A TButton (or rather its superclass TControl) does not have a Row or Column property. So we need to get a grip of the TControlItem wrapper the TGridpanel uses.
procedure TForm8.Button1Click(Sender: TObject);
var
selectedControl: TControl;
itemIndex: Integer;
selectedControlItem: TControlItem; // This knows about "Row" and "Column"
begin
// This is the button we've clicked
selectedControl := Sender as TControl;
itemIndex := GridPanel1.ControlCollection.IndexOf(selectedControl);
if (itemIndex <> -1) then begin
selectedControlItem := GridPanel1.ControlCollection.Items[itemIndex];
selectedControlItem.Row := Random(GridPanel1.RowCollection.Count);
selectedControlItem.Column := Random(GridPanel1.ColumnCollection.Count);
end;
end;
The above code finds the button and changes its Row and Column property to a random value. Note that you didn't specify whether the TButton is the only control within the TGridpanel. Is that the case?
I did the below in normal VCL and XE3 and with a TGridPanel (no TGridPanelLayout in my Delphi).
The problem with the GridPanel is that it does not allow controls (Buttons, etc) to be placed in any cell (like Cell:1,1) without having controls in the cells before that cell. GridPanel always fills itself from Index 0 upwards.
So the trick is to fool it. Now depending on whether you already have other cells in the GridPanel you will have to make place for the button to go to and also put something else in its place if the button was in a cell of lower index.
Have a look at the form before the button is pressed:
Note that I have not created a ControlItem at cell 1,0 yet.
I want to move Button 1 to cell 1,0. I cannot do that unless I first place something else in its place (cell 0,0). I have to create a new ControlItem at cell 1,0 to house button1.
procedure TForm1.Button1Click(Sender: TObject);
begin
// Places CheckBox1 in the same cell as BUtton1
GridPanel1.ControlCollection.ControlItems[0,0].Control := CheckBox1;
// Create a new ControlItem for Button1 and in the same breath move
// Button1 to it
GridPanel1.ControlCollection.AddControl(Button1,1,0);
// You know what this does. :)
CheckBox1.Parent := GridPanel1;
end;
The result:

Resources