change pokemon window from ListView to DataGridView and fix bugs

Detective Squirrel [2016-07-30 11:24:16]
change pokemon window from ListView to DataGridView and fix bugs

enable sorting Pokemon based on ID, name, CP, IV, Candy.
and also fix the bugs mentioned in the Master branch pull request
comments.
Filename
PokemonGo/RocketAPI/Window/PokeUi.Designer.cs
PokemonGo/RocketAPI/Window/PokeUi.cs
diff --git a/PokemonGo/RocketAPI/Window/PokeUi.Designer.cs b/PokemonGo/RocketAPI/Window/PokeUi.Designer.cs
index 16fa9be..f875958 100644
--- a/PokemonGo/RocketAPI/Window/PokeUi.Designer.cs
+++ b/PokemonGo/RocketAPI/Window/PokeUi.Designer.cs
@@ -28,130 +28,124 @@
         /// </summary>
         private void InitializeComponent()
         {
-			this.components = new System.ComponentModel.Container();
-			System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PokeUi));
-			this.listView1 = new System.Windows.Forms.ListView();
-			this.button1 = new System.Windows.Forms.Button();
-			this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
-			this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
-			this.button2 = new System.Windows.Forms.Button();
-			this.button3 = new System.Windows.Forms.Button();
-			this.btnUpgrade = new System.Windows.Forms.Button();
-			this.contextMenuStrip1.SuspendLayout();
-			this.SuspendLayout();
-			//
-			// listView1
-			//
-			this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
-            | System.Windows.Forms.AnchorStyles.Left)
-            | System.Windows.Forms.AnchorStyles.Right)));
-			this.listView1.Location = new System.Drawing.Point(16, 14);
-			this.listView1.Margin = new System.Windows.Forms.Padding(4);
-			this.listView1.Name = "listView1";
-			this.listView1.Size = new System.Drawing.Size(795, 458);
-			this.listView1.TabIndex = 0;
-			this.listView1.UseCompatibleStateImageBehavior = false;
-			this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged);
-			this.listView1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.listView1_MouseClick);
-			//
-			// button1
-			//
-			this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
-            | System.Windows.Forms.AnchorStyles.Right)));
-			this.button1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
-			this.button1.Location = new System.Drawing.Point(16, 489);
-			this.button1.Margin = new System.Windows.Forms.Padding(4);
-			this.button1.Name = "button1";
-			this.button1.Size = new System.Drawing.Size(795, 32);
-			this.button1.TabIndex = 3;
-			this.button1.Text = "Reload";
-			this.button1.UseVisualStyleBackColor = true;
-			this.button1.Click += new System.EventHandler(this.button1_Click);
-			//
-			// contextMenuStrip1
-			//
-			this.contextMenuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
-			this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+            this.components = new System.ComponentModel.Container();
+            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PokeUi));
+            this.btnReload = new System.Windows.Forms.Button();
+            this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
+            this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
+            this.btnEvolve = new System.Windows.Forms.Button();
+            this.btnTransfer = new System.Windows.Forms.Button();
+            this.btnUpgrade = new System.Windows.Forms.Button();
+            this.dataGridView1 = new System.Windows.Forms.DataGridView();
+            this.contextMenuStrip1.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
+            this.SuspendLayout();
+            //
+            // btnReload
+            //
+            this.btnReload.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
+            this.btnReload.Dock = System.Windows.Forms.DockStyle.Bottom;
+            this.btnReload.Location = new System.Drawing.Point(0, 573);
+            this.btnReload.Name = "btnReload";
+            this.btnReload.Size = new System.Drawing.Size(622, 26);
+            this.btnReload.TabIndex = 3;
+            this.btnReload.Text = "Reload";
+            this.btnReload.UseVisualStyleBackColor = true;
+            this.btnReload.Click += new System.EventHandler(this.button1_Click);
+            //
+            // contextMenuStrip1
+            //
+            this.contextMenuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
+            this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
             this.toolStripMenuItem1});
-			this.contextMenuStrip1.Name = "contextMenuStrip1";
-			this.contextMenuStrip1.Size = new System.Drawing.Size(137, 30);
-			//
-			// toolStripMenuItem1
-			//
-			this.toolStripMenuItem1.Name = "toolStripMenuItem1";
-			this.toolStripMenuItem1.Size = new System.Drawing.Size(136, 26);
-			this.toolStripMenuItem1.Text = "Transfer";
-			this.toolStripMenuItem1.Click += new System.EventHandler(this.toolStripMenuItem1_Click);
-			//
-			// button2
-			//
-			this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
-            | System.Windows.Forms.AnchorStyles.Right)));
-			this.button2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
-			this.button2.Location = new System.Drawing.Point(16, 529);
-			this.button2.Margin = new System.Windows.Forms.Padding(4);
-			this.button2.Name = "button2";
-			this.button2.Size = new System.Drawing.Size(795, 32);
-			this.button2.TabIndex = 4;
-			this.button2.Text = "Evolve Selected";
-			this.button2.UseVisualStyleBackColor = true;
-			this.button2.Click += new System.EventHandler(this.button2_Click);
-			//
-			// button3
-			//
-			this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
-            | System.Windows.Forms.AnchorStyles.Right)));
-			this.button3.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
-			this.button3.Location = new System.Drawing.Point(16, 609);
-			this.button3.Margin = new System.Windows.Forms.Padding(4);
-			this.button3.Name = "button3";
-			this.button3.Size = new System.Drawing.Size(795, 32);
-			this.button3.TabIndex = 5;
-			this.button3.Text = "Transfer Selected";
-			this.button3.UseVisualStyleBackColor = true;
-			this.button3.Click += new System.EventHandler(this.button3_Click);
-			//
-			// btnUpgrade
-			//
-			this.btnUpgrade.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
+            this.contextMenuStrip1.Name = "contextMenuStrip1";
+            this.contextMenuStrip1.Size = new System.Drawing.Size(118, 26);
+            //
+            // toolStripMenuItem1
+            //
+            this.toolStripMenuItem1.Name = "toolStripMenuItem1";
+            this.toolStripMenuItem1.Size = new System.Drawing.Size(117, 22);
+            this.toolStripMenuItem1.Text = "Transfer";
+            this.toolStripMenuItem1.Click += new System.EventHandler(this.toolStripMenuItem1_Click);
+            //
+            // btnEvolve
+            //
+            this.btnEvolve.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
+            this.btnEvolve.Dock = System.Windows.Forms.DockStyle.Bottom;
+            this.btnEvolve.Location = new System.Drawing.Point(0, 547);
+            this.btnEvolve.Name = "btnEvolve";
+            this.btnEvolve.Size = new System.Drawing.Size(622, 26);
+            this.btnEvolve.TabIndex = 4;
+            this.btnEvolve.Text = "Evolve Selected";
+            this.btnEvolve.UseVisualStyleBackColor = true;
+            this.btnEvolve.Click += new System.EventHandler(this.button2_Click);
+            //
+            // btnTransfer
+            //
+            this.btnTransfer.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
+            this.btnTransfer.Dock = System.Windows.Forms.DockStyle.Bottom;
+            this.btnTransfer.Location = new System.Drawing.Point(0, 521);
+            this.btnTransfer.Name = "btnTransfer";
+            this.btnTransfer.Size = new System.Drawing.Size(622, 26);
+            this.btnTransfer.TabIndex = 5;
+            this.btnTransfer.Text = "Transfer Selected";
+            this.btnTransfer.UseVisualStyleBackColor = true;
+            this.btnTransfer.Click += new System.EventHandler(this.button3_Click);
+            //
+            // btnUpgrade
+            //
+            this.btnUpgrade.Dock = System.Windows.Forms.DockStyle.Bottom;
+            this.btnUpgrade.Location = new System.Drawing.Point(0, 495);
+            this.btnUpgrade.Name = "btnUpgrade";
+            this.btnUpgrade.Size = new System.Drawing.Size(622, 26);
+            this.btnUpgrade.TabIndex = 6;
+            this.btnUpgrade.Text = "Upgrade Selected";
+            this.btnUpgrade.UseVisualStyleBackColor = true;
+            this.btnUpgrade.Click += new System.EventHandler(this.btnUpgrade_Click);
+            //
+            // dataGridView1
+            //
+            this.dataGridView1.AllowUserToAddRows = false;
+            this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+            | System.Windows.Forms.AnchorStyles.Left)
             | System.Windows.Forms.AnchorStyles.Right)));
-			this.btnUpgrade.Location = new System.Drawing.Point(16, 569);
-			this.btnUpgrade.Margin = new System.Windows.Forms.Padding(4);
-			this.btnUpgrade.Name = "btnUpgrade";
-			this.btnUpgrade.Size = new System.Drawing.Size(795, 32);
-			this.btnUpgrade.TabIndex = 6;
-			this.btnUpgrade.Text = "Upgrade Selected";
-			this.btnUpgrade.UseVisualStyleBackColor = true;
-			this.btnUpgrade.Click += new System.EventHandler(this.btnUpgrade_Click);
-			//
-			// PokeUi
-			//
-			this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
-			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-			this.ClientSize = new System.Drawing.Size(829, 664);
-			this.Controls.Add(this.btnUpgrade);
-			this.Controls.Add(this.button3);
-			this.Controls.Add(this.button2);
-			this.Controls.Add(this.button1);
-			this.Controls.Add(this.listView1);
-			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
-			this.Margin = new System.Windows.Forms.Padding(4);
-			this.Name = "PokeUi";
-			this.Text = "PokeUi";
-			this.Load += new System.EventHandler(this.PokeUi_Load);
-			this.contextMenuStrip1.ResumeLayout(false);
-			this.ResumeLayout(false);
+            this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
+            this.dataGridView1.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
+            this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+            this.dataGridView1.Location = new System.Drawing.Point(12, 12);
+            this.dataGridView1.Name = "dataGridView1";
+            this.dataGridView1.Size = new System.Drawing.Size(596, 477);
+            this.dataGridView1.TabIndex = 7;
+            this.dataGridView1.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellClick);
+            this.dataGridView1.SortCompare += new System.Windows.Forms.DataGridViewSortCompareEventHandler(this.dataGridView1_SortCompare);
+            //
+            // PokeUi
+            //
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(622, 599);
+            this.Controls.Add(this.dataGridView1);
+            this.Controls.Add(this.btnUpgrade);
+            this.Controls.Add(this.btnTransfer);
+            this.Controls.Add(this.btnEvolve);
+            this.Controls.Add(this.btnReload);
+            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
+            this.Name = "PokeUi";
+            this.Text = "PokeUi";
+            this.Load += new System.EventHandler(this.PokeUi_Load);
+            this.contextMenuStrip1.ResumeLayout(false);
+            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
+            this.ResumeLayout(false);

         }

         #endregion
-
-        private System.Windows.Forms.ListView listView1;
-        private System.Windows.Forms.Button button1;
+        private System.Windows.Forms.Button btnReload;
         private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
         private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
-        private System.Windows.Forms.Button button2;
-        private System.Windows.Forms.Button button3;
-		private System.Windows.Forms.Button btnUpgrade;
-	}
+        private System.Windows.Forms.Button btnEvolve;
+        private System.Windows.Forms.Button btnTransfer;
+        private System.Windows.Forms.Button btnUpgrade;
+        private System.Windows.Forms.DataGridView dataGridView1;
+    }
 }
\ No newline at end of file
diff --git a/PokemonGo/RocketAPI/Window/PokeUi.cs b/PokemonGo/RocketAPI/Window/PokeUi.cs
index 114ce62..c3f1a7c 100644
--- a/PokemonGo/RocketAPI/Window/PokeUi.cs
+++ b/PokemonGo/RocketAPI/Window/PokeUi.cs
@@ -53,15 +53,32 @@ namespace PokemonGo.RocketAPI.Window
                     .OrderByDescending(p => (int)p.FamilyId);


+                //listView1.ShowItemToolTips = true;

-                var imageSize = ClientSettings.ImageSize;
-
-                if ((imageSize > 96) || (imageSize < 1)) // no bigger than orig size and no smaller than 1x1
-                    imageSize = 50;
-
-                var imageList = new ImageList { ImageSize = new Size(imageSize, imageSize) };
-                //var imageList = new ImageList { ImageSize = new Size(96, 96) };
-                listView1.ShowItemToolTips = true;
+                //put data into gridview
+                this.dataGridView1.AutoGenerateColumns = false;
+                DataGridViewCheckBoxColumn checkbox = new DataGridViewCheckBoxColumn()
+                {
+                    HeaderText = "Checkbox",
+                    Name = "Checkbox",
+                    Visible = true
+                };
+                // add the new column to your dataGridView
+                this.dataGridView1.Columns.Insert(0, checkbox);
+                this.dataGridView1.Columns.Add("Image", "Image");
+                this.dataGridView1.Columns.Add("Name", "Name");
+                this.dataGridView1.Columns.Add("CP", "CP");
+                this.dataGridView1.Columns.Add("IV %", "IV %");
+                this.dataGridView1.Columns.Add("Candy", "Candy");
+                this.dataGridView1.Columns.Add("Number", "Number");
+                this.dataGridView1.Columns.Add("WeightKg", "WeightKg");
+                this.dataGridView1.Columns.Add("HeightM", "HeightM");
+
+                this.dataGridView1.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+                for (int i = 1; i < this.dataGridView1.Columns.Count; i++)
+                {
+                    this.dataGridView1.Columns[i].ReadOnly = true;
+                }

                 foreach (var pokemon in pokemons)
                 {
@@ -70,35 +87,35 @@ namespace PokemonGo.RocketAPI.Window
                     {
                         pokemonImage = GetPokemonImage((int)pokemon.PokemonId);
                     });
-                    imageList.Images.Add(pokemon.PokemonId.ToString(), pokemonImage);
-
-                    listView1.LargeImageList = imageList;
-                    var listViewItem = new ListViewItem();
-                    listViewItem.Tag = pokemon;
-

                     var currentCandy = families
                         .Where(i => (int)i.FamilyId <= (int)pokemon.PokemonId)
                         .Select(f => f.Candy)
                         .First();
                     var currIv = Math.Round(Perfect(pokemon));
-                    //listViewItem.SubItems.Add();
-                    listViewItem.ImageKey = pokemon.PokemonId.ToString();
+

                     var pokemonId2 = pokemon.PokemonId;
                     var pokemonName = pokemon.Id;

-                    listViewItem.Text = string.Format("{0}\n{1} CP", pokemon.PokemonId, pokemon.Cp);
-                    listViewItem.ToolTipText = currentCandy + " Candy\n" + currIv + "% IV";
-
-
-                    this.listView1.Items.Add(listViewItem);
-
+                    var row = new DataGridViewRow();
+                    //row.HeaderCell.Value = row.Index + 1 + "";
+                    row.Cells.Add(new DataGridViewCheckBoxCell { Value = false });
+                    row.Cells.Add(new DataGridViewImageCell { Value = pokemonImage });
+                    row.Cells.Add(new DataGridViewTextBoxCell { Value = pokemon.PokemonId });
+                    row.Cells.Add(new DataGridViewTextBoxCell { Value = pokemon.Cp });
+                    row.Cells.Add(new DataGridViewTextBoxCell { Value = currIv });
+                    row.Cells.Add(new DataGridViewTextBoxCell { Value = currentCandy });
+                    row.Cells.Add(new DataGridViewTextBoxCell { Value = (int)pokemon.PokemonId });
+                    row.Cells.Add(new DataGridViewTextBoxCell { Value = pokemon.WeightKg });
+                    row.Cells.Add(new DataGridViewTextBoxCell { Value = pokemon.HeightM });
+                    row.Tag = pokemon;
+                    this.dataGridView1.Rows.Add(row);
                 }
+
                 this.Text = "PokeUi " + pokemons.Count<PokemonData>() + "/" + profile.Profile.PokeStorage;
                 EnabledButton(true);

-
             }
             catch (TaskCanceledException) { Execute(); }
             catch (UriFormatException) { Execute(); }
@@ -110,9 +127,9 @@ namespace PokemonGo.RocketAPI.Window

         private void EnabledButton(bool enabled)
         {
-            button1.Enabled = enabled;
-            button2.Enabled = enabled;
-            button3.Enabled = enabled;
+            btnReload.Enabled = enabled;
+            btnEvolve.Enabled = enabled;
+            btnTransfer.Enabled = enabled;
             btnUpgrade.Enabled = enabled;
         }

@@ -127,15 +144,23 @@ namespace PokemonGo.RocketAPI.Window
                 WebClient wc = new WebClient();
                 wc.DownloadFile("http://pokeapi.co/media/sprites/pokemon/" + pokemonId + ".png", @location);
             }
+
+            var imageSize = ClientSettings.ImageSize;
+
+            if ((imageSize > 96) || (imageSize < 1)) // no bigger than orig size and no smaller than 1x1
+                imageSize = 50;
+
             PictureBox picbox = new PictureBox();
             picbox.Image = Image.FromFile(location);
-            Bitmap bitmapRemote = (Bitmap)picbox.Image;
+            Bitmap bitmapRemote = new Bitmap(picbox.Image, imageSize, imageSize);
             return bitmapRemote;
         }

         private void button1_Click(object sender, EventArgs e)
         {
-            this.listView1.Clear();
+            this.dataGridView1.DataSource = null;
+            this.dataGridView1.Columns.Clear();
+            this.dataGridView1.Rows.Clear();
             Execute();
         }

@@ -148,52 +173,62 @@ namespace PokemonGo.RocketAPI.Window
             return ((float)(poke.IndividualAttack + poke.IndividualDefense + poke.IndividualStamina) / (3.0f * 15.0f)) * 100.0f;
         }

-        private void listView1_MouseClick(object sender, MouseEventArgs e)
+        /*private void listView1_MouseClick(object sender, MouseEventArgs e)
         {
             if (e.Button == MouseButtons.Right)
             {
+                this.dataGridView1.
                 if (listView1.FocusedItem.Bounds.Contains(e.Location) == true)
                 {
                     contextMenuStrip1.Show(Cursor.Position);
                 }
             }
-        }
+        }*/

         private async void toolStripMenuItem1_Click(object sender, EventArgs e)
         {
-            var pokemon = (PokemonData)listView1.SelectedItems[0].Tag;
+            var pokemon = (PokemonData)this.dataGridView1.SelectedRows[0].Tag;


             if (MessageBox.Show(this, pokemon.PokemonId + " with " + pokemon.Cp + " CP thats " + Math.Round(Perfect(pokemon)) + "% perfect", "Are you sure you want to transfer?", MessageBoxButtons.OKCancel) == DialogResult.OK)
             {
                 var transfer = await client.TransferPokemon(pokemon.Id);
             }
-            listView1.Items.Remove(listView1.SelectedItems[0]);
+            this.dataGridView1.Rows.Remove(this.dataGridView1.SelectedRows[0]);
         }

         private async void button2_Click(object sender, EventArgs e)
         {
-            var selectedItems = this.listView1.SelectedItems;

-            foreach (ListViewItem selectedItem in selectedItems)
+            IEnumerable<DataGridViewRow> selectedItems = (from row in dataGridView1.Rows.Cast<DataGridViewRow>()
+                                                          where Convert.ToBoolean(((DataGridViewCheckBoxCell)row.Cells["Checkbox"]).EditedFormattedValue)
+                                                          select row).ToList();
+
+            foreach (DataGridViewRow selectedItem in selectedItems)
             {
                 await evolvePokemon((PokemonData)selectedItem.Tag);
             }

-            this.listView1.Clear();
+            this.dataGridView1.DataSource = null;
+            this.dataGridView1.Columns.Clear();
+            this.dataGridView1.Rows.Clear();
             Execute();
         }

         private async void button3_Click(object sender, EventArgs e)
         {
-            var selectedItems = this.listView1.SelectedItems;
+            IEnumerable<DataGridViewRow> selectedItems = (from row in dataGridView1.Rows.Cast<DataGridViewRow>()
+                                                          where Convert.ToBoolean(((DataGridViewCheckBoxCell)row.Cells["Checkbox"]).EditedFormattedValue)
+                                                          select row).ToList();

-            foreach (ListViewItem selectedItem in selectedItems)
+            foreach (DataGridViewRow selectedItem in selectedItems)
             {
                 await transferPokemon((PokemonData)selectedItem.Tag);
             }

-            this.listView1.Clear();
+            this.dataGridView1.DataSource = null;
+            this.dataGridView1.Columns.Clear();
+            this.dataGridView1.Rows.Clear();
             Execute();
         }

@@ -261,14 +296,18 @@ namespace PokemonGo.RocketAPI.Window

         private async void btnUpgrade_Click(object sender, EventArgs e)
         {
-            var selectedItems = listView1.SelectedItems;
+            IEnumerable<DataGridViewRow> selectedItems = (from row in dataGridView1.Rows.Cast<DataGridViewRow>()
+                                                          where Convert.ToBoolean(((DataGridViewCheckBoxCell)row.Cells["Checkbox"]).EditedFormattedValue)
+                                                          select row).ToList();

-            foreach (ListViewItem selectedItem in selectedItems)
+            foreach (DataGridViewRow selectedItem in selectedItems)
             {
                 await PowerUp((PokemonData)selectedItem.Tag);
             }

-            listView1.Clear();
+            this.dataGridView1.DataSource = null;
+            this.dataGridView1.Columns.Clear();
+            this.dataGridView1.Rows.Clear();
             Execute();
         }

@@ -302,5 +341,43 @@ namespace PokemonGo.RocketAPI.Window
             catch (NullReferenceException) { await PowerUp(pokemon); }
             catch (Exception ex) { await PowerUp(pokemon); }
         }
+
+        private void dataGridView1_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
+        {
+            //sort the numeric column
+            if (!e.Column.Name.Equals("Name") && !e.Column.Name.Equals("Image"))
+            {
+                e.SortResult = (Convert.ToDouble(e.CellValue1) - Convert.ToDouble(e.CellValue2) > 0) ? 1 : (Convert.ToDouble(e.CellValue1) - Convert.ToDouble(e.CellValue2) < 0) ? -1 : 0;
+            }
+
+            // if the value is same, then sort by IV
+            if (e.SortResult == 0 && e.Column.Name.Equals("IV %"))
+            {
+                e.SortResult = Convert.ToInt32(this.dataGridView1.Rows[e.RowIndex1].Cells["IV %"].Value.ToString()) -
+                        Convert.ToInt32(this.dataGridView1.Rows[e.RowIndex2].Cells["IV %"].Value.ToString());
+            }
+
+            e.Handled = true;
+        }
+
+
+        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
+        {
+            if (e.ColumnIndex != 0)
+                return;
+
+            bool isChecked = Convert.ToBoolean(this.dataGridView1.Rows[e.RowIndex].Cells["Checkbox"].EditedFormattedValue);
+
+            if (isChecked)
+            {
+                this.dataGridView1.Rows[e.RowIndex].Cells["Checkbox"].Value = true;
+                this.dataGridView1.Rows[e.RowIndex].Selected = true;
+            }
+            else
+            {
+                this.dataGridView1.Rows[e.RowIndex].Cells["Checkbox"].Value = false;
+                this.dataGridView1.Rows[e.RowIndex].Selected = false;
+            }
+        }
     }
-}
+}
\ No newline at end of file
You may download the files in Public Git.