b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

datagridview重叠_datagridview绑定list_datagridview右键菜单(51)

电脑杂谈  发布时间:2017-05-30 08:07:57  来源:网络整理

}

private void dataGridView1_SortCompare(object sender,

DataGridViewSortCompareEventArgs e)

{

// Try to sort based on the cells in the current column.

e.SortResult = System.String.Compare(

e.CellValue1.ToString(), e.CellValue2.ToString());

// If the cells are equal, sort based on the ID column.

if (e.SortResult == 0 && e.Column.Name != "ID")

{

e.SortResult = System.String.Compare(

dataGridView1.Rows[e.RowIndex1].Cells["ID"].Value.ToString(),

dataGridView1.Rows[e.RowIndex2].Cells["ID"].Value.ToString());

}

e.Handled = true;

}

}

9.2.2 Custom Sorting Using the IComparer Intece

The following code example demonstrates custom sorting using the Sort(IComparer) overload of the Sort method, which takes an implementation of the IComparer intece to perform a multiple-column sort.

using System;

using System.Drawing;

using System.Windows.Forms;

class Form1 : Form

{

private DataGridView DataGridView1 = new DataGridView();

private FlowLayoutPanel FlowLayoutPanel1 = new FlowLayoutPanel();

private Button Button1 = new Button();

private RadioButton RadioButton1 = new RadioButton();

private RadioButton RadioButton2 = new RadioButton();

// Establish the main entry point for the application.

[STAThreadAttribute()]

public static void Main()

{

Application.Run(new Form1());

}

public Form1()

{

// Initialize the form.

// This code can be replaced with designer generated code.

AutoSize = true;

Text = "DataGridView IComparer sort demo";

FlowLayoutPanel1.FlowDirection = FlowDirection.TopDown;


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/tongxinshuyu/article-50070-51.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...