C# -- DataGridView SortedColumn VALUE ?

finance_teacher
finance_teacher used Ask the Experts™
on
How can I change my below RO_MatReq_History.cs
"string vSortedColumn..." so it only extracts "DATEORIG"
instead of "DataGridViewTextBoxColumn { Name=DATEORIG, Index=7 }" ?
-----------------------------------------------------------------------
        private void btnPrint_Click(object sender, EventArgs e)
        {
            DateTime vStartDate = DateTime.Parse(this.vStartDateToolStripTextBox.Text);
            DateTime vEndDate = DateTime.Parse(this.vEndDateToolStripTextBox.Text);
            string vromid = this.vROMIDToolStripTextBox.Text;
            string vStockNumber = this.vIMIDToolStripTextBox.Text;
            string vSortedColumn = this.gML_ROITEMDataGridView.SortedColumn.ToString();
            RO_MatReq_History_Print frm = new RO_MatReq_History_Print(vStartDate, vEndDate, vStockNumber, vromid, vSortedColumn);
            frm.Show();
        }
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
hi,
use Name property column like :

    string vSortedColumn  = this.gML_ROITEMDataGridView.SortedColumn == null?string.Empty : this.gML_ROITEMDataGridView.SortedColumn.Name.ToString  ();  

Author

Commented:
Ok, the below works.

            string vSortedColumn = Convert.ToString(this.gML_ROITEMDataGridView.SortedColumn.Name);

How can I also extract "SORT ORDER" (i.e. DESC or acending)
since the below just says "Automatic" all the time ?

            string vSortedColumn = Convert.ToString(this.gML_ROITEMDataGridView.SortedColumn.SortMode);
you should get it by,

 string sOrder= this.gML_ROITEMDataGridView.SortOrder.ToString();  

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial