i




 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How the convert the code below form C#2008 to C#2005 have got Dictionary?
03-24-2015, 04:50 AM (This post was last modified: 03-24-2015 05:18 AM by dongtrien.)
Post: #1
Not Solved How the convert the code below form C#2008 to C#2005 have got Dictionary?
I want convert the code below form C#2008 to C#2005 have got Dictionary

Code:
Dictionary<GridCell, CellColors> cellColorsCahe = new Dictionary<GridCell, CellColors>();
void gridView1_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
        {
            foreach (var item in cellColorsCahe)
            {
                if (item.Key.RowHandle == e.RowHandle && item.Key.Column == e.Column)
                {
                    e.Appearance.ForeColor = item.Value.ForeColor;
                    e.Appearance.BackColor = item.Value.BackColor;
                }
            }
        }



Quote
03-24-2015, 06:25 AM
Post: #2
Not Solved RE: How the convert the code below form C#2008 to C#2005 have got Dictionary?
There is one way to make the similar code is to create a class which contain GridCell and CellColors Member and then add the class object into List Collection.

declare class like that
Code:
public class Cls_CellInfo
{
public GridCell Obj_GridCell = null;
public CellColors Obj_CellColors = null;
}

now create the list which datatype will be Cls_CellInfo
Code:
List<Cls_CellInfo> Lst_CellInfo = new List<Cls_CellInfo>();

now add the information to list like below
Code:
Cls_CellInfo Obj_Cls_CellInfo = new Cls_CellInfo();
Obj_Cls_CellInfo.Obj_GridCell= somevalue;
Obj_Cls_CellInfo.Obj_CellColors = somevalue;

Lst_CellInfo.Add(Obj_Cls_CellInfo);

now modify the code like below
Code:
void gridView1_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
        {
            foreach (Cls_CellInfo item in Lst_CellInfo)
            {
                if (item.Obj_GridCell.RowHandle == e.RowHandle && item.Obj_GridCell.Column == e.Column)
                {
                    e.Appearance.ForeColor = item.Obj_CellColors.ForeColor;
                    e.Appearance.BackColor = item.Obj_CellColors.BackColor;
                }
            }
        }

This code is just to demonstrate you the alternative way, so you need to adjust the code according to your code.

[Image: 2604595733.png]
Quote
03-24-2015, 09:56 AM
Post: #3
Not Solved RE: How the convert the code below form C#2008 to C#2005 have got Dictionary?
Please ask for more, in C # 2.0 support dictionnary, you can take advantage of using these ? instead use List
Quote


Possibly Related Threads...
Thread: Author Replies Views: Last Post
  Convert code C# 2008 to code C# 2005 ? dongtrien 0 1,163 02-25-2015 08:42 AM
Last Post: dongtrien
  Form not allowed to move or choose another form in C# ? dongtrien 2 1,403 07-01-2014 05:52 PM
Last Post: Elizabeth_Keen
  feedback form -->sending an email in ASP.net using C# code rcsp 1 1,294 08-27-2013 09:56 AM
Last Post: magnum_2007
  Dictionary with repeating keys C# xpert 1 1,739 01-01-2013 07:54 PM
Last Post: magnum_2007
  Manipulate Dictionary using LINQ in C# xpert 3 2,798 01-01-2013 08:07 AM
Last Post: magnum_2007



User(s) browsing this thread: 1 Guest(s)