• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Forms.DataGridViewSortCompareEventArgs类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Windows.Forms.DataGridViewSortCompareEventArgs的典型用法代码示例。如果您正苦于以下问题:C# DataGridViewSortCompareEventArgs类的具体用法?C# DataGridViewSortCompareEventArgs怎么用?C# DataGridViewSortCompareEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DataGridViewSortCompareEventArgs类属于System.Windows.Forms命名空间,在下文中一共展示了DataGridViewSortCompareEventArgs类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: EquipmentView_SortCompare

		private void EquipmentView_SortCompare( object sender, DataGridViewSortCompareEventArgs e ) {

			if ( e.Column.Index == EquipmentView_Name.Index ) {

				int id1 = (int)EquipmentView[EquipmentView_ID.Index, e.RowIndex1].Value;
				int id2 = (int)EquipmentView[EquipmentView_ID.Index, e.RowIndex2].Value;

				e.SortResult =
					KCDatabase.Instance.MasterEquipments[id1].CategoryType -
					KCDatabase.Instance.MasterEquipments[id2].CategoryType;

				if ( e.SortResult == 0 ) {
					e.SortResult = id1 - id2;
				}

			} else {

				e.SortResult = ( (IComparable)e.CellValue1 ).CompareTo( e.CellValue2 );

			}


			if ( e.SortResult == 0 ) {
				e.SortResult = ( EquipmentView.Rows[e.RowIndex1].Tag as int? ?? 0 ) - ( EquipmentView.Rows[e.RowIndex2].Tag as int? ?? 0 );
			}

			e.Handled = true;

		}
开发者ID:hirsaeki,项目名称:ElectronicObserver,代码行数:29,代码来源:DialogEquipmentList.cs


示例2: DataGridView_SortCompare

 void DataGridView_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
 {
     //verifica se é a mesma coluna, se não for... ignora
     if(e.Column.Index == this.Index)
     {
         double cellValue1 = Double.Parse(Unimake.Utilities.OnlyNumbers(e.CellValue1).ToString());
         double cellValue2 = Double.Parse(Unimake.Utilities.OnlyNumbers(e.CellValue2).ToString());
         e.SortResult = cellValue1.CompareTo(cellValue2);
         e.Handled = true;
     }
 }
开发者ID:njmube,项目名称:openposbr,代码行数:11,代码来源:DataGridViewNumericColumn.cs


示例3: dgvWirelessNetworks_SortCompare

 private void dgvWirelessNetworks_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
 {
     if (e.Column.Index == 4)
     {
         int a = int.Parse(e.CellValue1.ToString());
         int b = int.Parse(e.CellValue2.ToString());
         // If the cell value is already an integer, just cast it instead of parsing
         e.SortResult = a.CompareTo(b);
         e.Handled = true;
     }
 }
开发者ID:Salz150,项目名称:SalzWifiUtility,代码行数:11,代码来源:frmMain.cs


示例4: dataGridSymbols_SortCompare

 private void dataGridSymbols_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
 {
     if (e.Column.Index > 0)
     {
         e.Handled = true;
         int val1;
         int val2;
         Int32.TryParse(e.CellValue1.ToString(), out val1);
         Int32.TryParse(e.CellValue2.ToString(), out val2);
         e.SortResult = val1 - val2;
     }
 }
开发者ID:Genst,项目名称:crunchersharp,代码行数:12,代码来源:CruncherSharp.cs


示例5: dataGridViewStorage_SortCompare

        void dataGridViewStorage_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
        {
            if (e.Column == ColumnDevicePosition)
            {
                e.SortResult = StringUtility.NaturalCompare(e.CellValue1.ToString(), e.CellValue2.ToString());

                e.Handled = true;
            }
            else
            {
                e.Handled = false;
            }
        }
开发者ID:robhoes,项目名称:xenadmin,代码行数:13,代码来源:VMStoragePage.cs


示例6: dgrid_SortCompare

        /// <summary>
        /// manejador del evento SortCompare de la grilla
        /// </summary>
        /// <param name="sender">Objeto donde se generó el evento --> la grilla</param>
        /// <param name="e">Argumento del evento que contiene información sobre las filas y columnas que se comparan</param>
        private void dgrid_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
        {
            // si la columna es de tipo int, entonces realiza el ordenamiento de números enteros
            if (e.Column.ValueType == typeof(int))
            {
                // obtiene el valor entero de cada celda
                int value1 = int.Parse(e.CellValue1.ToString());
                int value2 = int.Parse(e.CellValue2.ToString());

                // compara dichos valores usando el método CompareTo de la clase int. La clase int implemente IComparable<int>
                e.SortResult = value1.CompareTo(value2);

                // indica que se realizó el manejo del evento
                e.Handled = true;
            }
            // si la columna es de tipo decimal, entonces realiza el ordenamiento de números decimales
            else if (e.Column.ValueType == typeof(decimal))
            {
                // obtiene el valor decimal de cada celda
                decimal value1 = decimal.Parse(e.CellValue1.ToString());
                decimal value2 = decimal.Parse(e.CellValue2.ToString());

                // compara dichos valores usando el método CompareTo de la clase decimal. La clase decimal implemente IComparable<decimal>
                e.SortResult = value1.CompareTo(value2);

                // indica que se realizó el manejo del evento
                e.Handled = true;
            }
            // si la columna es de tipo DateTime, entonces realiza el ordenamiento de fechas
            else if (e.Column.ValueType == typeof(DateTime))
            {
                // obtiene el valor fecha de cada celda
                DateTime value1 = DateTime.Parse(e.CellValue1.ToString());
                DateTime value2 = DateTime.Parse(e.CellValue2.ToString());

                // compara dichos valores usando el método CompareTo de la clase DateTime. La clase DateTime implemente IComparable<DateTime>
                e.SortResult = value1.CompareTo(value2);

                // indica que se realizó el manejo del evento
                e.Handled = true;
            }
        }
开发者ID:andrescabrera,项目名称:LenguajesVisualesI,代码行数:47,代码来源:DataGridViewHelper.cs


示例7: dgvLeases_SortCompare

        private void dgvLeases_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
        {
            string val1 = e.CellValue1?.ToString() ?? "";
            string val2 = e.CellValue2?.ToString() ?? "";

            //TODO: This is inefficient, requires potentially processing the same IPAddress or Date values over and over again
            //       It doesn't seem to cause noticable delays, so low priority, but I'd still like to refactor
            //       this to re-use parsed values.
            int result = 0;
            if (val1 == "" && val2 != "")
            {
                result = -1;
            }
            else if (val1 != "" && val2 == "")
            {
                result = 1;
            }
            else if (val1 == "" && val2 == "")
            {
                result = 0;
            }
            //neither value is empty. Now we can process special columns
            else if (e.Column.HeaderText == "IP Address")
            {
                uint v1 = (uint)System.Net.IPAddress.NetworkToHostOrder((int)System.Net.IPAddress.Parse(val1).Address);
                uint v2 = (uint)System.Net.IPAddress.NetworkToHostOrder((int)System.Net.IPAddress.Parse(val2).Address);
                result = v1.CompareTo(v2);
            }
            else if (e.Column.HeaderText == "Expires")
            {
                DateTime v1 = DateTime.Parse(val1);
                DateTime v2 = DateTime.Parse(val2);
                result = v1.CompareTo(v2);
            }
            //default
            else
            {
                result = val1.CompareTo(val2);
            }
            e.SortResult = result;
            e.Handled = true;
        }
开发者ID:jcoehoorn,项目名称:DHCPViewer,代码行数:42,代码来源:Form1.cs


示例8: ShipView_SortCompare

        private void ShipView_SortCompare( object sender, DataGridViewSortCompareEventArgs e )
        {
            if ( e.Column.Index == ShipView_Name.Index ) {
                e.SortResult =
                    KCDatabase.Instance.MasterShips[(int)ShipView.Rows[e.RowIndex1].Cells[e.Column.Index].Tag].AlbumNo -
                    KCDatabase.Instance.MasterShips[(int)ShipView.Rows[e.RowIndex2].Cells[e.Column.Index].Tag].AlbumNo;

            } else if ( e.Column.Index == ShipView_Exp.Index ) {
                e.SortResult = (int)e.CellValue1 - (int)e.CellValue2;
                if ( e.SortResult == 0 )	//for Lv.99-100
                    e.SortResult = (int)ShipView[ShipView_Level.Index, e.RowIndex1].Value - (int)ShipView[ShipView_Level.Index, e.RowIndex2].Value;

            } else if (
                e.Column.Index == ShipView_HP.Index ||
                e.Column.Index == ShipView_Fuel.Index ||
                e.Column.Index == ShipView_Ammo.Index ||
                e.Column.Index == ShipView_Aircraft1.Index ||
                e.Column.Index == ShipView_Aircraft2.Index ||
                e.Column.Index == ShipView_Aircraft3.Index ||
                e.Column.Index == ShipView_Aircraft4.Index ||
                e.Column.Index == ShipView_Aircraft5.Index ||
                e.Column.Index == ShipView_AircraftTotal.Index
                ) {
                Fraction frac1 = (Fraction)e.CellValue1, frac2 = (Fraction)e.CellValue2;

                double rate = frac1.Rate - frac2.Rate;

                if ( rate > 0.0 )
                    e.SortResult = 1;
                else if ( rate < 0.0 )
                    e.SortResult = -1;
                else
                    e.SortResult = frac1.Current - frac2.Current;

            } else if ( e.Column.Index == ShipView_Fleet.Index ) {
                if ( (string)e.CellValue1 == "" ) {
                    if ( (string)e.CellValue2 == "" )
                        e.SortResult = 0;
                    else
                        e.SortResult = 1;
                } else {
                    if ( (string)e.CellValue2 == "" )
                        e.SortResult = -1;
                    else
                        e.SortResult = ( (string)e.CellValue1 ).CompareTo( e.CellValue2 );
                }

            } else {
                e.SortResult = (int)e.CellValue1 - (int)e.CellValue2;
            }

            if ( e.SortResult == 0 ) {
                e.SortResult = (int)ShipView.Rows[e.RowIndex1].Tag - (int)ShipView.Rows[e.RowIndex2].Tag;

                if ( ShipView.SortOrder == SortOrder.Descending )
                    e.SortResult = -e.SortResult;
            }

            e.Handled = true;
        }
开发者ID:bllue78,项目名称:ElectronicObserver,代码行数:60,代码来源:FormShipGroup.cs


示例9: DataGridViewObject_SortCompare

 void DataGridViewObject_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
 {
     if (e.Column.Index == sizeColumn.Index)
     {
         VDI vdi1 = ((VDIRow)dataGridViewVDIs.Rows[e.RowIndex1]).VDI;
         VDI vdi2 = ((VDIRow)dataGridViewVDIs.Rows[e.RowIndex2]).VDI;
         long diff = vdi1.virtual_size - vdi2.virtual_size;
         e.SortResult =
             diff > 0 ? 1 :
             diff < 0 ? -1 :
                        0;
         e.Handled = true;
     }
 }
开发者ID:robertbreker,项目名称:xenadmin,代码行数:14,代码来源:SrStoragePage.cs


示例10: OnSortCompare

		protected virtual void OnSortCompare (DataGridViewSortCompareEventArgs e) {
			DataGridViewSortCompareEventHandler eh = (DataGridViewSortCompareEventHandler)(Events [SortCompareEvent]);
			if (eh != null) eh (this, e);
		}
开发者ID:vnan122,项目名称:mono,代码行数:4,代码来源:DataGridView.cs


示例11: sharedFilesDataGridView_SortCompare

        private void sharedFilesDataGridView_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
        {
            switch (e.Column.Name)
            {
                case "RatingIcon":
                    e.SortResult = ((byte)sharedFilesDataGridView.Rows[e.RowIndex1].Cells[e.Column.Name].Tag + ((RandomTag<string>)sharedFilesDataGridView.Rows[e.RowIndex1].Tag).SortTag).CompareTo((byte)sharedFilesDataGridView.Rows[e.RowIndex2].Cells[e.Column.Name].Tag + ((RandomTag<string>)sharedFilesDataGridView.Rows[e.RowIndex2].Tag).SortTag);
                    e.Handled = true;
                    break;
                case "FileSize":
                    // 2007-05-17 T.Norad: fix for big files
                    e.SortResult = ((long)sharedFilesDataGridView.Rows[e.RowIndex1].Cells[e.Column.Name].Tag + ((RandomTag<string>)sharedFilesDataGridView.Rows[e.RowIndex1].Tag).SortTag).CompareTo((long)sharedFilesDataGridView.Rows[e.RowIndex2].Cells[e.Column.Name].Tag + ((RandomTag<string>)sharedFilesDataGridView.Rows[e.RowIndex2].Tag).SortTag);
                    e.Handled = true;
                    break;
                case "lastRequest":
                    // get the first value to compare from grid
                    object date1 = sharedFilesDataGridView.Rows[e.RowIndex1].Cells[e.Column.Name].Tag;
                    // second value from grid
                    object date2 = sharedFilesDataGridView.Rows[e.RowIndex2].Cells[e.Column.Name].Tag;

                    e.SortResult = SortHelper.compareDates(date1, date2);
                    // if the datetime equal we use the sort tag to prevent flickering sort results
                    if (e.SortResult == 0)
                    {
                        e.SortResult = ((RandomTag<string>)sharedFilesDataGridView.Rows[e.RowIndex1].Tag).SortTag.CompareTo(((RandomTag<string>)sharedFilesDataGridView.Rows[e.RowIndex2].Tag).SortTag);
                    }
                    e.Handled = true;
                    break;
            }
        }
开发者ID:Steeslice,项目名称:StealthNet-Alt,代码行数:29,代码来源:SharedFilesControl.cs


示例12: dataGridView1_SortCompare

 private void dataGridView1_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
 {
     try {
         if (e.Column.Name.Equals("CSize")) {
             //if (e.CellValue1.Equals(e.CellValue2)) {
             //    e.SortResult = -1;
             //    e.Handled = true;
             //}
             String[] data1 = MyReg.Reg_GetFirstMutiString(e.CellValue1.ToString(), "(\\d+\\.?\\d*)+\\s*(GB|MB)");
             String[] data2 = MyReg.Reg_GetFirstMutiString(e.CellValue2.ToString(), "(\\d+\\.?\\d*)+\\s*(GB|MB)");
             double ddata1 = double.Parse(data1[0]); int flag1 = data1[1].Equals("MB") ? 0 : 1;
             double ddata2 = double.Parse(data2[0]); int flag2 = data2[1].Equals("MB") ? 0 : 1;
             int flag = flag1 - flag2;
             if (flag == 0) { //单位相同比大小
                 flag = (ddata1 - ddata2) >= 0 ? 1 : -1;
             }
             e.SortResult = flag;
             e.Handled = true;
         } else if (e.Column.Name.Equals("CHot") || e.Column.Name.Equals("CNum")) {//热度排序和index排序
             int data1 = MyReg.Reg_GetFirstNum(e.CellValue1.ToString(), "(\\d+)");
             int data2 = MyReg.Reg_GetFirstNum(e.CellValue2.ToString(), "(\\d+)");
             e.SortResult = data1 - data2;
             e.Handled = true; //不要会炸
         }
     }
     catch (Exception ee) {
         Console.WriteLine("我日了狗"+ee.Message);
     }
     //   如果是学号或成绩列,则按浮点数处理
     //if (e.Column.Name == "大小")
     //{
     //    if(data1.)
     //    e.SortResult = (Convert.ToDouble(e.CellValue1) - Convert.ToDouble(e.CellValue2) > 0) ? 1 : (Convert.ToDouble(e.CellValue1) - Convert.ToDouble(e.CellValue2) < 0) ? -1 : 0;
     //    e.Handled = true;
     //}
     ////否则,按字符串比较
     //else
     //{
     //    return;
     //}
 }
开发者ID:langren1353,项目名称:ACKan,代码行数:41,代码来源:MainForm.cs


示例13: connectionsDataGridView_SortCompare

 private void connectionsDataGridView_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
 {
     switch (e.Column.Name)
     {
         case "IPAddress":
             e.SortResult = ((uint)connectionsDataGridView.Rows[e.RowIndex1].Cells[e.Column.Name].Tag + ((RandomTag<IPAddress>)connectionsDataGridView.Rows[e.RowIndex1].Tag).SortTag).CompareTo((uint)connectionsDataGridView.Rows[e.RowIndex2].Cells[e.Column.Name].Tag + ((RandomTag<IPAddress>)connectionsDataGridView.Rows[e.RowIndex2].Tag).SortTag);
             e.Handled = true;
             break;
         case "EnqueuedCommands":
             e.SortResult = ((int)connectionsDataGridView.Rows[e.RowIndex1].Cells[e.Column.Name].Tag + ((RandomTag<IPAddress>)connectionsDataGridView.Rows[e.RowIndex1].Tag).SortTag).CompareTo((int)connectionsDataGridView.Rows[e.RowIndex2].Cells[e.Column.Name].Tag + ((RandomTag<IPAddress>)connectionsDataGridView.Rows[e.RowIndex2].Tag).SortTag);
             e.Handled = true;
             break;
         case "Port":
         case "Sent":
         case "Received":
         case "SentCommands":
         case "ReceivedCommands":
             e.SortResult = ((long)connectionsDataGridView.Rows[e.RowIndex1].Cells[e.Column.Name].Tag + ((RandomTag<IPAddress>)connectionsDataGridView.Rows[e.RowIndex1].Tag).SortTag).CompareTo((long)connectionsDataGridView.Rows[e.RowIndex2].Cells[e.Column.Name].Tag + ((RandomTag<IPAddress>)connectionsDataGridView.Rows[e.RowIndex2].Tag).SortTag);
             e.Handled = true;
             break;
     }
 }
开发者ID:Steeslice,项目名称:StealthNet-Alt,代码行数:22,代码来源:ConnectionsControl.cs


示例14: dataGridViewUpdates_SortCompare

        private void dataGridViewUpdates_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
        {
            Alert alert1 = (Alert)dataGridViewUpdates.Rows[e.RowIndex1].Tag;
            Alert alert2 = (Alert)dataGridViewUpdates.Rows[e.RowIndex2].Tag;

            if (e.Column.Index == ColumnMessage.Index)
            {
                e.SortResult = Alert.CompareOnTitle(alert1, alert2);
                e.Handled = true;
            }
            else if (e.Column.Index == ColumnReleaseDate.Index)
            {
                e.SortResult = Alert.CompareOnDate(alert1, alert2);
                e.Handled = true;
            }
            else if (e.Column.Index == ColumnWebPage.Index)
            {
                e.SortResult = Alert.CompareOnWebPage(alert1, alert2);
                e.Handled = true;
            }
            else if (e.Column.Index == ColumnAppliesTo.Index)
            {
                e.SortResult = Alert.CompareOnAppliesTo(alert1, alert2);
                e.Handled = true;
            }
        }
开发者ID:ko-85,项目名称:xenadmin,代码行数:26,代码来源:ManageUpdatesDialog.cs


示例15: dgvMethod_SortCompare

 private void dgvMethod_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
 {
     if (e.CellValue1 != null && e.CellValue2 != null)
     {
         string valueString1 = e.CellValue1.ToString();
         string valueString2 = e.CellValue2.ToString();
         if (e.Column.Name.Equals("ColCodeNum"))
         {
             float value1 = 0f;
             float value2 = 0f;
             float.TryParse(valueString1, out value1);
             float.TryParse(valueString2, out value2);
             e.SortResult = Comparer.DefaultInvariant.Compare(value1, value2);
         }
         else
         {
             e.SortResult = string.Compare(valueString1, valueString2);
         }
     }
     e.Handled = true;
 }
开发者ID:loozhang,项目名称:XP.CodeStatistics,代码行数:21,代码来源:FormAssemblyDetail.cs


示例16: customSortCompare

        private void customSortCompare(object sender, DataGridViewSortCompareEventArgs e)
        {
            int temp;
            bool isNumeric = int.TryParse(e.CellValue1.ToString(), out temp);
            if (!isNumeric)
                return;
            int a = int.Parse(e.CellValue1.ToString()), b = int.Parse(e.CellValue2.ToString());

            // If the cell value is already an integer, just cast it instead of parsing

            e.SortResult = a.CompareTo(b);

            e.Handled = true;
        }
开发者ID:JeromeVancouver,项目名称:DraftDayGuide,代码行数:14,代码来源:fmMain.cs


示例17: dataGridView1_SortCompare

        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;
        }
开发者ID:CaptDreamer,项目名称:Pokemon-Go-Rocket-API,代码行数:17,代码来源:PokeUi.cs


示例18: downloadsDataGridView_SortCompare

        private void downloadsDataGridView_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
        {
            switch (e.Column.Name)
            {
                case "RatingIcon":
                    e.SortResult = ((byte)downloadsDataGridView.Rows[e.RowIndex1].Cells[e.Column.Name].Tag + ((RandomTag<string>)downloadsDataGridView.Rows[e.RowIndex1].Tag).SortTag).CompareTo((byte)downloadsDataGridView.Rows[e.RowIndex2].Cells[e.Column.Name].Tag + ((RandomTag<string>)downloadsDataGridView.Rows[e.RowIndex2].Tag).SortTag);
                    e.Handled = true;
                    break;
                case "FileSize":
                case "Completed":
                case "Remaining":
                    // 2007-05-20 T.Norad
                    // fix for big files
                    e.SortResult = ((long)downloadsDataGridView.Rows[e.RowIndex1].Cells[e.Column.Name].Tag + ((RandomTag<string>)downloadsDataGridView.Rows[e.RowIndex1].Tag).SortTag).CompareTo((long)downloadsDataGridView.Rows[e.RowIndex2].Cells[e.Column.Name].Tag + ((RandomTag<string>)downloadsDataGridView.Rows[e.RowIndex2].Tag).SortTag);
                    e.Handled = true;
                    break;
                case "Status": // 2008-03-20 Nochbaer
                case "Sources":
                case "lastReception":
                    // 2007-06-10 T.Norad
                    // fix: Sources are int-values
                    e.SortResult = ((int)downloadsDataGridView.Rows[e.RowIndex1].Cells[e.Column.Name].Tag + ((RandomTag<string>)downloadsDataGridView.Rows[e.RowIndex1].Tag).SortTag).CompareTo((int)downloadsDataGridView.Rows[e.RowIndex2].Cells[e.Column.Name].Tag + ((RandomTag<string>)downloadsDataGridView.Rows[e.RowIndex2].Tag).SortTag);
                    e.Handled = true;
                    break;
                case "ProgressImage":
                    e.SortResult = ((float)downloadsDataGridView.Rows[e.RowIndex1].Cells[e.Column.Name].Tag + ((RandomTag<string>)downloadsDataGridView.Rows[e.RowIndex1].Tag).SortTag / 100).CompareTo((float)downloadsDataGridView.Rows[e.RowIndex2].Cells[e.Column.Name].Tag + ((RandomTag<string>)downloadsDataGridView.Rows[e.RowIndex2].Tag).SortTag / 100);
                    e.Handled = true;
                    break;
                case "lastSeen":
                    // get the first value to compare from grid
                    object date1 = downloadsDataGridView.Rows[e.RowIndex1].Cells[e.Column.Name].Tag;
                    // second value from grid
                    object date2 = downloadsDataGridView.Rows[e.RowIndex2].Cells[e.Column.Name].Tag;

                    e.SortResult = SortHelper.compareDates(date1, date2);
                    // if the datetime equal we use the sort tag to prevent flickering sort results
                    if (e.SortResult == 0)
                    {
                        e.SortResult = ((RandomTag<string>)downloadsDataGridView.Rows[e.RowIndex1].Tag).SortTag.CompareTo(((RandomTag<string>)downloadsDataGridView.Rows[e.RowIndex2].Tag).SortTag);
                    }
                    e.Handled = true;
                    break;
            }
        }
开发者ID:Steeslice,项目名称:StealthNet-Alt,代码行数:44,代码来源:DownloadsControl.cs


示例19: GridViewAlerts_SortCompare

 /// <summary>
 /// Handles the automatic sorting of the AlertsGridView for the non-string columns
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void GridViewAlerts_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
 {
     Alert alert1 = (Alert)GridViewAlerts.Rows[e.RowIndex1].Tag;
     Alert alert2 = (Alert)GridViewAlerts.Rows[e.RowIndex2].Tag;
     if (e.Column.Index == ColumnDate.Index)
     {
         int SortResult = DateTime.Compare(alert1.Timestamp, alert2.Timestamp);
         e.SortResult = (GridViewAlerts.SortOrder == SortOrder.Descending) ? SortResult *= -1 : SortResult;
         e.Handled = true;
     }
     else if (e.Column.Index == ColumnSeverity.Index)
     {
         e.SortResult = Alert.CompareOnPriority(alert1, alert2);
         e.Handled = true;
     }
 }
开发者ID:huizh,项目名称:xenadmin,代码行数:21,代码来源:AlertSummaryPage.cs


示例20: sourcesDataGridView_SortCompare

 private void sourcesDataGridView_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
 {
     switch (e.Column.Name)
     {
         case "TypeIcon":
             e.SortResult = ((int)DateTime.Now.Subtract((DateTime)sourcesDataGridView.Rows[e.RowIndex1].Cells[e.Column.Name].Tag).TotalMinutes + ((RandomTag<string>)sourcesDataGridView.Rows[e.RowIndex1].Tag).SortTag).CompareTo((int)DateTime.Now.Subtract((DateTime)sourcesDataGridView.Rows[e.RowIndex2].Cells[e.Column.Name].Tag).TotalMinutes + ((RandomTag<string>)sourcesDataGridView.Rows[e.RowIndex2].Tag).SortTag);
             e.Handled = true;
             break;
         case "Queue":
         case "Type":
             e.SortResult = ((int)sourcesDataGridView.Rows[e.RowIndex1].Cells[e.Column.Name].Tag + ((RandomTag<string>)sourcesDataGridView.Rows[e.RowIndex1].Tag).SortTag).CompareTo((int)sourcesDataGridView.Rows[e.RowIndex2].Cells[e.Column.Name].Tag + ((RandomTag<string>)sourcesDataGridView.Rows[e.RowIndex2].Tag).SortTag);
             e.Handled = true;
             break;
         case "SentCommands":
         case "ReceivedCommands":
             e.SortResult = ((long)sourcesDataGridView.Rows[e.RowIndex1].Cells[e.Column.Name].Tag + ((RandomTag<string>)sourcesDataGridView.Rows[e.RowIndex1].Tag).SortTag).CompareTo((long)sourcesDataGridView.Rows[e.RowIndex2].Cells[e.Column.Name].Tag + ((RandomTag<string>)sourcesDataGridView.Rows[e.RowIndex2].Tag).SortTag);
             e.Handled = true;
             break;
     }
 }
开发者ID:Steeslice,项目名称:StealthNet-Alt,代码行数:20,代码来源:DownloadsControl.cs



注:本文中的System.Windows.Forms.DataGridViewSortCompareEventArgs类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Forms.DataGridViewTextBoxCell类代码示例发布时间:2022-05-26
下一篇:
C# Forms.DataGridViewRowsRemovedEventArgs类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap