//This code developed by Ramy Mahrous 
//ramyamahrous@hotmail.com
//Its contents is provided "as is", without warranty.

/// <summary>
/// Represents Student object
/// </summary>
public class Student
{
int id;
public int ID
{
get { return id; }
set { id = value; }
}
string firstName;
public string FirstName
{
get { return firstName; }
set { firstName = value; }
}
string lastName;
public string LastName
{
get { return lastName; }
set { lastName = value; }
}
public string FullName
{
get { return firstName + " " + lastName; }
}
public Student(int id, string firstName, string lastName)
{
this.id = id;
this.firstName = firstName;
this.lastName = lastName;
}
}

/// <summary>
/// Binds collection of students to ComboBox
/// </summary>
public void Bind()
{
Student[] students = new Student[6];

students[0] = new Student(1, "Ramy", "Mahrous");
students[1] = new Student(2, "FCI", "Helwan");
students[2] = new Student(3, "Danny", "");
students[3] = new Student(4, "Serkan", "Sendur");
students[4] = new Student(5, "Scott", "");
students[5] = new Student(6, "adatapost", "Y");

comboBox1.Items.AddRange(students);

comboBox1.DataSource = students;
comboBox1.ValueMember = "ID";
comboBox1.DisplayMember = "FullName";
}
3
Contributors
4
Replies
14
Views
7 Years
Discussion Span
Last Post by Ramy Mahrous
0

cant you use binding source for this?

Do not force your self, they are not going to make you featured coder, they are not interested in csharp. go and write some javascript if you want to get promoted :)

0

I cant understand the lineno 54. what is its purpose.

comboBox1.Items.AddRange(students);

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.