Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread TListBox selection update
Tue, Oct 13 2015 8:02 PMPermanent Link

Roland

WinXP, EWB 2.02, Chrome test browsers on both current and separate computers.

I have a TlistBox linked to a dataset column with a string data type. I also have a TDatasetToolBar linked to the dataset with First, Prior, Next, Last and Save buttons exposed.

I use the list box to provide User-input options appropriate to the value of a second column in the dataset. To do this I create 2 TStrings variables, populate them in the form's initialization and simply assign the appropriate variable to the listbox's items in the dataset's AfterScroll event:

//==========================================================
procedure TWorkForm.WorkOrderTasksAfterScroll(Sender: TObject);
var
  ExpectedOutcome: string;
begin
  ExpectedOutcome:= WorkOrderTasks.Columns['ExpectedOutcome'].AsString;
  case ExpectedOutcome of
     'Yes','No': TaskOutComeLBox.Items.Assign(Outcomes1);
     'Done and OK': TaskOutComeLBox.Items.Assign(Outcomes2);
  end;{case}
//   TaskOutcomeLBox.DataColumn:= '';
//   TaskOutcomeLBox.DataColumn:= 'TaskOutcome';
  TaskDocumentFile.Visible:= (TaskDocumentFile.URL <> '');
  TasksP.CaptionBar.Caption:= 'Tasks ('
     + IntToStr(WorkOrderTasks.RowNo)
     + ' of '
     + IntToStr(WorkOrderTasks.RowCount) + ')';
end;
//==========================================================

When opening the dataset and scrolling the records all appears to work correctly with the listbox selecting the matching item on the list.

Problem:

I select a different value in the list box and click the Save button to save the record locally (No changes on the server and no dataset event code other than the AfterScroll event above).

I then scroll to a different record and scroll back to the modified one - the item selection bar in the list box (indicating the current value in the underlying column) is absent and the listbox's ItemIndex reports -1 even though the underlying column value reports as correct.

I have worked around this by clearing and resetting the listbox's DataColumn property after the items assignment code in the AfterScroll event above.

Is this an error on my part, a bug or is there a better way of doing this?

Roland
Roland
Wed, Oct 14 2015 2:17 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roland,

<< Is this an error on my part, a bug or is there a better way of doing this? >>

Can you send me a sample project that reproduces this ?  I'll need to trace this to see exactly what is going on with the values that you're using and how they relate to the dataset values.

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Oct 15 2015 1:40 AMPermanent Link

Roland

Tim

Attached is a test sample as requested. I have included the SQL to generate the respective table which I query for the data.

The database is DBISAM Ver 4.26 Build 2

Roland



Attachments: EWBTest.zip
Mon, Oct 19 2015 4:20 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roland,

Thanks for the example.  This is now fixed and the fix will be included in the next 2.02 B2.

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Oct 19 2015 7:46 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roland,

BTW, here's the hot fix:

WebLists unit (implementation):

procedure TListControl.ItemsChanged;
begin
  if DataBound then   <<<<<<<< Add
     RowChanged(Column);   <<<<<<<< Add
................

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Oct 20 2015 9:40 PMPermanent Link

Roland

Tim Young [Elevate Software] wrote:

Roland,

BTW, here's the hot fix:

WebLists unit (implementation):

procedure TListControl.ItemsChanged;
begin
  if DataBound then   <<<<<<<< Add
     RowChanged(Column);   <<<<<<<< Add
................

Tim Young
Elevate Software
www.elevatesoft.com

Thanks Tim

That's fixed it.

Roland
Image