Skip to content

Commit 342f8a4

Browse files
author
saravanan.ayyanar
committed
How to create the custom column in winforms datagrid
1 parent 96cfee6 commit 342f8a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+3764
-0
lines changed

RatingColumn/Employee.cs

Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
#region Copyright Syncfusion Inc. 2001-2018.
2+
// Copyright Syncfusion Inc. 2001-2018. All rights reserved.
3+
// Use of this code is subject to the terms of our license.
4+
// A copy of the current license can be obtained at any time by e-mailing
5+
// licensing@syncfusion.com. Any infringement will be prosecuted under
6+
// applicable laws.
7+
#endregion
8+
using System;
9+
using System.Collections.Generic;
10+
using System.ComponentModel;
11+
using System.ComponentModel.DataAnnotations;
12+
using System.Linq;
13+
using System.Text;
14+
15+
namespace GettingStarted
16+
{
17+
public class Employee : INotifyPropertyChanged
18+
{
19+
#region Private members
20+
21+
private bool _selected;
22+
private string _name;
23+
private string _designation;
24+
private string _mail;
25+
private string _trust;
26+
private string _status;
27+
private int _proficiency;
28+
private int _rating;
29+
private int _salary;
30+
private string _address;
31+
private string _gender;
32+
33+
34+
#endregion
35+
36+
public Employee(bool selected, string name, string designation, string mail, string location, string trust, int rating, string status, int proficiency, int salary, string address, string gender)
37+
{
38+
Selected = selected;
39+
EmployeeName = name;
40+
Designation = designation;
41+
Mail = mail;
42+
Location = location;
43+
Trustworthiness = trust;
44+
Rating = rating;
45+
Status = status;
46+
SoftwareProficiency = proficiency;
47+
Salary = salary;
48+
Address = address;
49+
Gender = gender;
50+
}
51+
52+
public bool Selected
53+
{
54+
get
55+
{
56+
return _selected;
57+
}
58+
set
59+
{
60+
_selected = value;
61+
RaisePropertyChanged("Selected");
62+
}
63+
}
64+
/// <summary>
65+
/// Gets or sets the employee name.
66+
/// </summary>
67+
[Display(Name = "Employee Name ")]
68+
public string EmployeeName
69+
{
70+
get
71+
{
72+
return _name;
73+
}
74+
set
75+
{
76+
_name = value;
77+
RaisePropertyChanged("EmployeeName");
78+
}
79+
}
80+
81+
/// <summary>
82+
/// Gets or sets the designation.
83+
/// </summary>
84+
[Display(Name = "Designation ")]
85+
public string Designation
86+
{
87+
get
88+
{
89+
return _designation;
90+
}
91+
set
92+
{
93+
_designation = value;
94+
RaisePropertyChanged("Designation");
95+
}
96+
}
97+
98+
/// <summary>
99+
/// Gets or sets the mail ID.
100+
/// </summary>
101+
[Display(Name = "Mail")]
102+
public string Mail
103+
{
104+
get
105+
{
106+
return _mail;
107+
}
108+
set
109+
{
110+
_mail = value;
111+
RaisePropertyChanged("Mail");
112+
}
113+
}
114+
115+
/// <summary>
116+
/// Gets or sets the location.
117+
/// </summary>
118+
[Display(Name = "Location")]
119+
public string Location { get; set; }
120+
121+
/// <summary>
122+
/// Gets or sets the Trustworthiness.
123+
/// </summary>
124+
[Display(Name = "Trustworthiness")]
125+
public string Trustworthiness
126+
{
127+
get
128+
{
129+
return _trust;
130+
}
131+
set
132+
{
133+
_trust = value;
134+
RaisePropertyChanged("Trustworthiness");
135+
}
136+
}
137+
138+
/// <summary>
139+
/// Gets or sets the rating.
140+
/// </summary>
141+
[Display(Name = "Rating")]
142+
public int Rating
143+
{
144+
get
145+
{
146+
return _rating;
147+
}
148+
set
149+
{
150+
_rating = value;
151+
RaisePropertyChanged("Rating");
152+
}
153+
}
154+
155+
/// <summary>
156+
/// Gets or sets the status.
157+
/// </summary>
158+
[Display(Name = "Status")]
159+
public string Status
160+
{
161+
get
162+
{
163+
return _status;
164+
}
165+
set
166+
{
167+
_status = value;
168+
RaisePropertyChanged("Status");
169+
}
170+
}
171+
172+
/// <summary>
173+
/// Gets or sets the software proficiency .
174+
/// </summary>
175+
[Display(Name = "Software Proficiency")]
176+
public int SoftwareProficiency
177+
{
178+
get
179+
{
180+
return _proficiency;
181+
}
182+
set
183+
{
184+
_proficiency = value;
185+
RaisePropertyChanged("SoftwareProficiency");
186+
}
187+
}
188+
189+
/// <summary>
190+
/// Gets or sets the salary.
191+
/// </summary>
192+
[Display(Name = "Salary")]
193+
public int Salary
194+
{
195+
get
196+
{
197+
return _salary;
198+
}
199+
set
200+
{
201+
_salary = value;
202+
RaisePropertyChanged("Salary");
203+
}
204+
}
205+
206+
/// <summary>
207+
/// Gets or sets the address.
208+
/// </summary>
209+
[Display(Name = "Address")]
210+
public string Address
211+
{
212+
get
213+
{
214+
return _address;
215+
}
216+
set
217+
{
218+
_address = value;
219+
RaisePropertyChanged("Address");
220+
}
221+
}
222+
223+
/// <summary>
224+
/// Gets or sets the Gender.
225+
/// </summary>
226+
[Display(Name = "Gender")]
227+
public string Gender
228+
{
229+
get
230+
{
231+
return _gender;
232+
}
233+
set
234+
{
235+
_gender = value;
236+
RaisePropertyChanged("Gender");
237+
}
238+
}
239+
240+
241+
public event PropertyChangedEventHandler PropertyChanged;
242+
243+
public void RaisePropertyChanged(string propertyName)
244+
{
245+
if (this.PropertyChanged != null)
246+
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
247+
}
248+
}
249+
}

RatingColumn/EmployeeCollection.cs

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#region Copyright Syncfusion Inc. 2001-2018.
2+
// Copyright Syncfusion Inc. 2001-2018. All rights reserved.
3+
// Use of this code is subject to the terms of our license.
4+
// A copy of the current license can be obtained at any time by e-mailing
5+
// licensing@syncfusion.com. Any infringement will be prosecuted under
6+
// applicable laws.
7+
#endregion
8+
using System;
9+
using System.Collections.Generic;
10+
using System.Collections.ObjectModel;
11+
using System.Linq;
12+
using System.Text;
13+
14+
namespace GettingStarted
15+
{
16+
public class EmployeeCollection
17+
{
18+
public EmployeeCollection()
19+
{
20+
EmployeeDetails = new EmployeeRepository().GetEmployeeDetails(100);
21+
}
22+
23+
private ObservableCollection<Employee> _EmployeeDetails;
24+
25+
/// <summary>
26+
/// Gets or sets the orders details.
27+
/// </summary>
28+
/// <value>The orders details.</value>
29+
public ObservableCollection<Employee> EmployeeDetails
30+
{
31+
get { return _EmployeeDetails; }
32+
set { _EmployeeDetails = value; }
33+
}
34+
}
35+
36+
public class EmployeeRepository
37+
{
38+
39+
/// <summary>
40+
/// Initializes a new instance of the <see cref="EmployeeRepository"/> class.
41+
/// </summary>
42+
public EmployeeRepository()
43+
{
44+
}
45+
46+
/// <summary>
47+
/// Gets the Employee details.
48+
/// </summary>
49+
/// <param name="count">The count.</param>
50+
/// <returns></returns>
51+
public ObservableCollection<Employee> GetEmployeeDetails(int count)
52+
{
53+
string[] employees = { "Michael", "Kathryn", "Tamer", "Martin", "Davolio", "Nancy", "Fuller", "Leverling", "Therasa",
54+
"Margaret", "Buchanan", "Janet", "Andrew", "Callahan", "Laura", "Dodsworth", "Anne",
55+
"Bergs", "Vinet", "Anto", "Fleet", "Zachery", "Van", "Edward", "Jack", "Rose"};
56+
string[] genders = { "1", "2", "1", "1", "2", "2", "1", "2", "2", "2", "1", "2", "1", "1", "2", "1", "2", "1", "1", "1", "1", "1", "1", "1", "1", "2" };
57+
58+
string[] designation = { "Manager", "CFO", "Designer", "Developer", "Program Directory", "System Analyst", "Project Lead" };
59+
60+
string[] mail = { "gmail.com", "yahoo.com", "hotmail.com" };
61+
string[] trust = { "Sufficient", "Perfect", "Insufficient" };
62+
string[] status = { "Active", "Inactive" };
63+
string[] location = { "UK", "USA", "Sweden", "France", "Canada", "Argentina", "Austria", "Germany", "Mexico" };
64+
65+
string[] address = { "59 rue de lAbbaye", "Luisenstr. 48"," Rua do Paço 67", "2 rue du Commerce", "Boulevard Tirou 255",
66+
"Rua do mailPaço 67", "Hauptstr. 31", "Starenweg 5", "Rua do Mercado, 12",
67+
"Carrera 22 con Ave."," Carlos Soublette #8-35", "Kirchgasse 6",
68+
"Sierras de Granada 9993", "Mehrheimerstr. 369", "Rua da Panificadora 12", "2817 Milton Dr.", "Kirchgasse 6",
69+
"Åkergatan 24", "24, place Kléber", "Torikatu 38", "Berliner Platz 43", "5ª Ave. Los Palos Grandes", "1029 - 12th Ave. S.",
70+
"Torikatu 38", "P.O. Box 555", "2817 Milton Dr.", "Taucherstraße 10", "59 rue de lAbbaye", "Via Ludovico il Moro 22",
71+
"Avda. Azteca 123", "Heerstr. 22", "Berguvsvägen 8", "Magazinweg 7", "Berguvsvägen 8", "Gran Vía, 1", "Gran Vía, 1",
72+
"Carrera 52 con Ave. Bolívar #65-98 Llano Largo", "Magazinweg 7", "Taucherstraße 10", "Taucherstraße 10"};
73+
74+
75+
Random random = new Random();
76+
ObservableCollection<Employee> ordersDetails = new ObservableCollection<Employee>();
77+
78+
for (int i = 10000; i < count + 10000; i++)
79+
{
80+
var name = employees[random.Next(25)];
81+
int index = Array.IndexOf(employees, name);
82+
string gender = genders[index];
83+
ordersDetails.Add(new Employee(i % 2 == -1, name, designation[random.Next(6)], name.ToLower() + "@" + mail[random.Next(3)], location[random.Next(8)], trust[random.Next(3)],random.Next(1,5), status[random.Next(2)], random.Next(1, 100), random.Next(100000, 400000), address[random.Next(1, 25)], gender));
84+
}
85+
86+
return ordersDetails;
87+
}
88+
}
89+
}

0 commit comments

Comments
 (0)