Click here to Skip to main content
14,357,121 members
   

C#

 
GeneralRe: Help with WMI Connect Remotely Pin
mniceguy819-Oct-19 10:40
membermniceguy819-Oct-19 10:40 
QuestionSimple API to record AVI Files Pin
TyrionTheImp9-Oct-19 3:03
memberTyrionTheImp9-Oct-19 3:03 
AnswerRe: Simple API to record AVI Files Pin
Richard MacCutchan9-Oct-19 3:49
protectorRichard MacCutchan9-Oct-19 3:49 
QuestionWhy is the dataGridView1_SortCompare function not working ? Pin
Member 24584679-Oct-19 0:29
memberMember 24584679-Oct-19 0:29 
QuestionRe: Why is the dataGridView1_SortCompare function not working ? Pin
Richard MacCutchan9-Oct-19 0:37
protectorRichard MacCutchan9-Oct-19 0:37 
AnswerRe: Why is the dataGridView1_SortCompare function not working ? Pin
Member 24584679-Oct-19 16:20
memberMember 24584679-Oct-19 16:20 
GeneralRe: Why is the dataGridView1_SortCompare function not working ? Pin
Richard MacCutchan9-Oct-19 22:38
protectorRichard MacCutchan9-Oct-19 22:38 
GeneralRe: Why is the dataGridView1_SortCompare function not working ? Pin
Member 245846710-Oct-19 19:17
memberMember 245846710-Oct-19 19:17 
I will post code does not work, I will post my code for you to see, what am I wrong with ?
public partial class Form1 : Form
   {
        public Form1()
        {
            InitializeComponent();
            //sort colum header
            this.dataGridView1.VirtualMode = false;
            this.dataGridView1.SortCompare += new System.Windows.Forms.DataGridViewSortCompareEventHandler(this.dataGridView1_SortCompare);

            dataGridView1.DataSource = CreateTable(5);

        }

        private static DataTable CreateTable(int RowCount)
        {
            DataTable tbl = new DataTable();
            tbl.Columns.Add("check1", typeof(bool));
            tbl.Columns.Add("ID", typeof(int));
            tbl.Columns.Add("Name", typeof(string));
            tbl.Columns.Add("Number", typeof(int));
            tbl.Columns.Add("Date", typeof(DateTime));
            tbl.Columns.Add("check2", typeof(bool));
            for (int i = 0; i < RowCount; i++)
                tbl.Rows.Add(new object[] { false, i, String.Format("Name{0}", i), 3 - i, DateTime.Now.AddDays(i), true });
            return tbl;
        }

        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;
        }

    }
image file http://www.mediafire.com/view/9ogb4uwvfr2ag3i/dgv2.jpg/file
GeneralRe: Why is the dataGridView1_SortCompare function not working ? Pin
Richard MacCutchan10-Oct-19 23:03
protectorRichard MacCutchan10-Oct-19 23:03 
GeneralRe: Why is the dataGridView1_SortCompare function not working ? Pin
Member 245846714-Oct-19 21:52
memberMember 245846714-Oct-19 21:52 
GeneralRe: Why is the dataGridView1_SortCompare function not working ? Pin
Richard MacCutchan14-Oct-19 23:00
protectorRichard MacCutchan14-Oct-19 23:00 
GeneralRe: Why is the dataGridView1_SortCompare function not working ? Pin
Member 245846717-Oct-19 18:21
memberMember 245846717-Oct-19 18:21 
Questionunexpected behavior of DataContract serializer: C# language issue Pin
BillWoodruff8-Oct-19 9:07
mveBillWoodruff8-Oct-19 9:07 
AnswerRe: unexpected behavior of DataContract serializer: C# language issue Pin
Eddy Vluggen8-Oct-19 9:52
mveEddy Vluggen8-Oct-19 9:52 
AnswerRe: unexpected behavior of DataContract serializer: C# language issue Pin
Richard Deeming8-Oct-19 9:59
mveRichard Deeming8-Oct-19 9:59 
GeneralRe: unexpected behavior of DataContract serializer: C# language issue Pin
BillWoodruff8-Oct-19 13:50
mveBillWoodruff8-Oct-19 13:50 
QuestionHelp to get only IPv4 address Pin
mniceguy818-Oct-19 8:14
membermniceguy818-Oct-19 8:14 
AnswerRe: Help to get only IPv4 address Pin
Richard MacCutchan8-Oct-19 9:02
protectorRichard MacCutchan8-Oct-19 9:02 
AnswerRe: Help to get only IPv4 address Pin
Richard Deeming8-Oct-19 9:54
mveRichard Deeming8-Oct-19 9:54 
GeneralRe: Help to get only IPv4 address Pin
mniceguy819-Oct-19 4:51
membermniceguy819-Oct-19 4:51 
GeneralRe: Help to get only IPv4 address Pin
Richard Deeming9-Oct-19 8:36
mveRichard Deeming9-Oct-19 8:36 
GeneralRe: Help to get only IPv4 address Pin
mniceguy819-Oct-19 8:41
membermniceguy819-Oct-19 8:41 
QuestionDoes the Visual studio C#.net have a progressBar and a control line ? Pin
Member 24584677-Oct-19 0:34
memberMember 24584677-Oct-19 0:34 
AnswerRe: Does the Visual studio C#.net have a progressBar and a control line ? Pin
Afzaal Ahmad Zeeshan7-Oct-19 0:44
mveAfzaal Ahmad Zeeshan7-Oct-19 0:44 
GeneralRe: Does the Visual studio C#.net have a progressBar and a control line ? Pin
Member 24584677-Oct-19 17:41
memberMember 24584677-Oct-19 17:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.