當前位置: 首頁>>代碼示例>>C#>>正文


C# Forms.DataGridViewSortCompareEventArgs類代碼示例

本文整理匯總了C#中System.Windows.Forms.DataGridViewSortCompareEventArgs的典型用法代碼示例。如果您正苦於以下問題:C# DataGridViewSortCompareEventArgs類的具體用法?C# DataGridViewSortCompareEventArgs怎麽用?C# DataGridViewSortCompareEventArgs使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DataGridViewSortCompareEventArgs類屬於System.Windows.Forms命名空間,在下文中一共展示了DataGridViewSortCompareEventArgs類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的System.Windows.Forms.DataGridViewSortCompareEventArgs類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。