Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: What is the best method for on click d/click in stringgrid on IOS.


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 1 - Last Post: Jan 12, 2015 5:02 PM Last Post By: Stev Warby
Stev Warby

Posts: 50
Registered: 10/19/14
What is the best method for on click d/click in stringgrid on IOS.  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 12, 2015 1:39 AM
HI,

1. I am producing a quotation app on IOS using a stringgrid to select from the products and populate another stringgrid.

However using this method the click are not correctly ( a random row is selected).

procedure TTabbedForm.StringGrid2Click(Sender: TObject);
var
selectedRow,buttonSelected, newRow : Integer;
selectedCode, selectedDesc : String;
begin
selectedRow := StringGrid2.Selected;
selectedCode := StringGrid2.Cells[0,selectedRow];
selectedDesc := StringGrid2.Cells[1,selectedRow];
// buttonSelected := MessageDlg('Confirmation',mtError, mbOKCancel, 0);
buttonSelected := MessageDlg('Add '+ selectedCode +' to quote', TMsgDlgType.mtError, mbOKCancel, 0);
//buttonSelected := 1;
// Show the button type selected
if buttonSelected = mrOK then
begin
//ShowMessage('OK pressed');
//showmessage('you selected ' + selectedCode + ' desc' + selectedDesc);
newRow := SGCustomerDetails.RowCount ;
SGCustomerDetails.RowCount := SGCustomerDetails.RowCount + 1;
SGCustomerDetails.cells[0,newRow] := '1';
SGCustomerDetails.cells[1,newRow] := selectedCode;
SGCustomerDetails.cells[2,newRow] := selectedDesc;
SGCustomerDetails.SetFocus;

//showmessage('you selected ' + selectedCompany + ' image' + selectedCompanyImage);
end;
if buttonSelected = mrCancel then ShowMessage('Cancel pressed');
end;

2. I also need to be able to delete a row from the populated string grid. I am using an on d/click event and running this code:

procedure TTabbedForm.SGCustomerDetailsDblClick(Sender: TObject);
var
selectedRow,buttonSelected : Integer;
codeToDelete : string;
i, j: Integer;
begin
selectedRow := SGCustomerDetails.Selected;;
codeToDelete := SGCustomerDetails.Cells[1,selectedRow];
//selectedCompanyImage := SGCustomerDetails.Cells[3,selectedRow];
// buttonSelected := MessageDlg('Confirmation',mtError, mbOKCancel, 0);
buttonSelected := MessageDlg('Delete row '+ codeToDelete , TMsgDlgType.mtError, mbOKCancel, 0);
// Show the button type selected
if buttonSelected = mrOK then
begin
//ShowMessage('OK pressed');

with SGCustomerDetails do
begin
for i := selectedRow to RowCount-2 do
for j := 0 to ColumnCount-1 do
Cells[j, i] := Cells[j, i+1];
RowCount := RowCount - 1
end;

// showmessage('you selected ' + selectedCompany + ' image' + selectedCompanyImage);
end;
if buttonSelected = mrCancel then ShowMessage('Cancel pressed');
end;

This works fine under windows but not on mobile.

Is there a way I can add a button in the stringgrid row to action the delete row code ?


Thanks.

Stev Warby

Posts: 50
Registered: 10/19/14
Re: What is the best method for on click d/click in stringgrid on IOS.  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 12, 2015 5:02 PM   in response to: Stev Warby in response to: Stev Warby
I have changed to using a ListView and have been able to customise the ListView for the product list for selection.

On the on click event I can get the correct values. (ie no false triggers). I am presuming the grids are not optimised for mobiles.

I now need to build up a list with the following fields that will work on mobile.

Quantity (edit field) - PartNumber (Label) - Desc (Label) - Cost (edit field) - delete row (button).

I tried this with another ListView but it does not have enough columns for what I need.

Is there a method to do this with a listView ?

I also see a ListBox but cannot add what I need to this.

Any ideas or code would be appreciated.

Thanks.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02