OSDN Git Service

ComboBoxの動作チェック
authorjiro <yamat0jp@yahoo.co.jp>
Thu, 12 Mar 2015 11:33:08 +0000 (20:33 +0900)
committerjiro <yamat0jp@yahoo.co.jp>
Thu, 12 Mar 2015 11:33:08 +0000 (20:33 +0900)
Unit1.pas

index 7592efb..af42cfc 100644 (file)
--- a/Unit1.pas
+++ b/Unit1.pas
@@ -97,6 +97,7 @@ begin
     begin
       ListView1.ItemIndex := 0;
       Image1.Bitmap.Assign(ListView1.Items[0].Bitmap);
+      Randomize;
     end;
   end;
 end;
@@ -119,7 +120,7 @@ begin
       then
       begin
         s := Image1.Children[i];
-        (s as TEffect).Enabled:=true;
+        (s as TEffect).Enabled := true;
         FloatAnimation1.Parent := s;
         SetObjectProp(s, 'target',
           ListView1.Items[ListView1.ItemIndex + 1].Bitmap);
@@ -131,9 +132,9 @@ end;
 
 procedure TForm1.Button3Click(Sender: TObject);
 var
-  i: integer;
+  i: Integer;
 begin
-  for i := ListView1.Items.Count-1 downto 0 do
+  for i := ListView1.Items.Count - 1 downto 0 do
     if ListView1.Items[i].Checked = true then
       ListView1.Items.Delete(i);
 end;
@@ -180,9 +181,21 @@ begin
 end;
 
 procedure TForm1.MenuItem8Click(Sender: TObject);
+var
+  s: string;
+  i: Integer;
 begin
+  if ComboBox1.Items.Count > 0 then
+    s := ComboBox1.Items[ComboBox1.ItemIndex];
   if Form2.ShowModal = mrOK then
+  begin
     ComboBox1.Items.Assign(Form2.ListBox2.Items);
+    i := ComboBox1.Items.IndexOf(s);
+    if i > -1 then
+      ComboBox1.ItemIndex := i
+    else if ComboBox1.Items.Count > 0 then
+      ComboBox1.ItemIndex := 0;
+  end;
 end;
 
 end.