I want to be able to read a value that a user has just selected in a ComboBoxColumn or a ListColumn. I have tried using the following code for a ListColumn in a number of different events(OnCloseUp, onselect, OnAfterEdit, onchange, etc.), but I only get the previous value, not the new value:
var
SelectedText: string;
begin
SelectedText := colUserStatus.Items[grdUsers.Cell[1, grdUsers.SelectedRow].AsInteger];
CodeSite.Send('SelectedText', SelectedText);
end;
Thanks.
Reading a Value from a ComboBoxColumn or List Column.
Started by Speed, Jun 28 2012 03:20 AM
3 replies to this topic
#1
Posted 28 June 2012 - 03:20 AM
#2
Posted 28 June 2012 - 03:28 AM
Is this the correct way:
procedure TfrmMain.colUserStatusCloseUp(Sender: TObject);
var
SelectedText: string;
begin
SelectedText := colUserStatus.Editor.AsString;
CodeSite.Send('SelectedText', SelectedText);
end;
procedure TfrmMain.colUserStatusCloseUp(Sender: TObject);
var
SelectedText: string;
begin
SelectedText := colUserStatus.Editor.AsString;
CodeSite.Send('SelectedText', SelectedText);
end;
#3
Posted 28 June 2012 - 09:54 AM
Hi
You can also use the column's OnCloseUp event provided that you call ApplyEditing first:
This will work for ComboBoxColumn and ListColumn, but note that for a ListColumn the value that is returned is the underlying index of the selected item - not the actual text in the cell.
You can also use the column's OnCloseUp event provided that you call ApplyEditing first:
procedure TForm1.NxComboBoxColumn1CloseUp(Sender: TObject); begin NextGrid1.ApplyEditing; ShowMessage(NextGrid1.Cell[NextGrid1.SelectedColumn,NextGrid1.SelectedRow].AsString); end;
This will work for ComboBoxColumn and ListColumn, but note that for a ListColumn the value that is returned is the underlying index of the selected item - not the actual text in the cell.
#4
Posted 29 June 2012 - 01:03 AM
I
I didn't know about ApplyEditing - thanks for that.
deonvn, on 28 June 2012 - 09:54 AM, said:
Hi
You can also use the column's OnCloseUp event provided that you call ApplyEditing first:
This will work for ComboBoxColumn and ListColumn, but note that for a ListColumn the value that is returned is the underlying index of the selected item - not the actual text in the cell.
You can also use the column's OnCloseUp event provided that you call ApplyEditing first:
procedure TForm1.NxComboBoxColumn1CloseUp(Sender: TObject); begin NextGrid1.ApplyEditing; ShowMessage(NextGrid1.Cell[NextGrid1.SelectedColumn,NextGrid1.SelectedRow].AsString); end;
This will work for ComboBoxColumn and ListColumn, but note that for a ListColumn the value that is returned is the underlying index of the selected item - not the actual text in the cell.
I didn't know about ApplyEditing - thanks for that.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











