Click here to Skip to main content
15,887,267 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# VS 2008 3.5 Winform SetFocus to textbox on Ctrl + L Pin
Wheels01229-Dec-09 5:56
Wheels01229-Dec-09 5:56 
GeneralRe: C# VS 2008 3.5 Winform SetFocus to textbox on Ctrl + L Pin
TheFoZ29-Dec-09 5:59
TheFoZ29-Dec-09 5:59 
GeneralRe: C# VS 2008 3.5 Winform SetFocus to textbox on Ctrl + L Pin
Wheels01229-Dec-09 6:10
Wheels01229-Dec-09 6:10 
GeneralRe: C# VS 2008 3.5 Winform SetFocus to textbox on Ctrl + L Pin
TheFoZ29-Dec-09 21:30
TheFoZ29-Dec-09 21:30 
GeneralRe: C# VS 2008 3.5 Winform SetFocus to textbox on Ctrl + L Pin
Wheels01230-Dec-09 1:34
Wheels01230-Dec-09 1:34 
GeneralRe: C# VS 2008 3.5 Winform SetFocus to textbox on Ctrl + L Pin
Luc Pattyn29-Dec-09 6:23
sitebuilderLuc Pattyn29-Dec-09 6:23 
GeneralRe: C# VS 2008 3.5 Winform SetFocus to textbox on Ctrl + L Pin
TheFoZ29-Dec-09 21:24
TheFoZ29-Dec-09 21:24 
QuestionSorting using generic classes + c# Pin
abcurl29-Dec-09 5:17
abcurl29-Dec-09 5:17 
Language - c#
Database - sql server 2008
DataGridview

It is regarding the sorting in the datagridview using generic classes as a datasource of datagridview
I need suggestion for my implementation that whether my approach is right or wrong

Following are the function.

private void datagridview1_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {           
            SetSorting(e.ColumnIndex);
        }

private void SetSorting(int ColumnIndex)
        {
            if (ColumnIndex == -1) return;
            IList<classInfo> data = null;
            try
            {
                data = (IList&lt;classInfo&gt;)dgvUploadCharts.DataSource;
                SortOrder order = SortGlyphDirectionPublication(ColumnIndex);
                dgvUploadCharts.DataSource = SortingDataPublication(data, order, ColumnIndex);
                dgvUploadCharts.Columns[ColumnIndex].HeaderCell.SortGlyphDirection = order;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                data = null;
            }
        }

private IList<classInfo> SortingDataPublication(IList<classInfo> Obj, SortOrder SortOrder, int ColumnIndex)
{
    IEnumerable<classInfo> sortedEnum = null;
            try
            {
                if (datagridview1.Columns[ColumnIndex].Name.ToString() == Enumeration.Enum1.ToString())
                {
                    if (SortOrder == SortOrder.Ascending || SortOrder == SortOrder.None)
                        sortedEnum = Obj.OrderBy(f => f.Enum1);
                    if (SortOrder == SortOrder.Descending)
                        sortedEnum = Obj.OrderByDescending(f => f.Enum1);
                    return sortedEnum.ToList();
                }
	    }
}


private SortOrder SortGlyphDirectionPublication(int ColumnIndex)
        {
            SortOrder order = datagridview1.Columns[ColumnIndex].HeaderCell.SortGlyphDirection;
            if (order == SortOrder.None)
                return SortOrder.Ascending;
            if (order == SortOrder.Ascending)
                return SortOrder.Descending;
            if (order == SortOrder.Descending)
                return SortOrder.Ascending;
            return SortOrder.Ascending;
        }

AnswerRe: Sorting using generic classes + c# Pin
Eddy Vluggen29-Dec-09 6:20
professionalEddy Vluggen29-Dec-09 6:20 
Questionc# multiple forms communication Pin
ikurtz29-Dec-09 4:31
ikurtz29-Dec-09 4:31 
AnswerRe: c# multiple forms communication Pin
Saksida Bojan29-Dec-09 4:48
Saksida Bojan29-Dec-09 4:48 
AnswerRe: c# multiple forms communication Pin
dan!sh 29-Dec-09 5:03
professional dan!sh 29-Dec-09 5:03 
AnswerRe: c# multiple forms communication Pin
coolestCoder29-Dec-09 22:23
coolestCoder29-Dec-09 22:23 
QuestionI have a few questions :) Pin
Raztor029-Dec-09 4:30
Raztor029-Dec-09 4:30 
AnswerRe: I have a few questions :) Pin
Saksida Bojan29-Dec-09 4:41
Saksida Bojan29-Dec-09 4:41 
AnswerRe: I have a few questions :) Pin
DiscoJimmy29-Dec-09 5:01
DiscoJimmy29-Dec-09 5:01 
AnswerRe: I have a few questions :) Pin
Raztor029-Dec-09 7:37
Raztor029-Dec-09 7:37 
GeneralRe: I have a few questions :) Pin
Saksida Bojan29-Dec-09 8:12
Saksida Bojan29-Dec-09 8:12 
QuestionWindows automation with C# Pin
DiscoJimmy29-Dec-09 4:26
DiscoJimmy29-Dec-09 4:26 
QuestionResize of Custom Control And Excluding control Pin
Saksida Bojan29-Dec-09 4:02
Saksida Bojan29-Dec-09 4:02 
AnswerRe: Resize of Custom Control And Excluding control Pin
Eddy Vluggen29-Dec-09 6:34
professionalEddy Vluggen29-Dec-09 6:34 
GeneralRe: Resize of Custom Control And Excluding control Pin
Saksida Bojan29-Dec-09 10:30
Saksida Bojan29-Dec-09 10:30 
GeneralRe: Resize of Custom Control And Excluding control Pin
Eddy Vluggen30-Dec-09 5:45
professionalEddy Vluggen30-Dec-09 5:45 
GeneralRe: Resize of Custom Control And Excluding control Pin
Saksida Bojan5-Jan-10 1:49
Saksida Bojan5-Jan-10 1:49 
GeneralRe: Resize of Custom Control And Excluding control Pin
Saksida Bojan12-Feb-10 19:03
Saksida Bojan12-Feb-10 19:03 

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.