Need C# code sample in .NET Core Windows Forms designer

  • Thread starter Thread starter zydjohn
  • Start date Start date
Z

zydjohn

Guest
Hello:
I recently upgrade Visual Studio 2019 to version 16.5.0, and I want to convert some of my .NET core code to use .NET Core Windows Forms designer.
The following was part of my original code:

public class StudenGrade
{
public int CourseID { get; set; }
public int Grade { get; set; }
public string Student { get; set; }
}

class Program
{
static void Main()
{
List<StudenGrade> all_grades = new List<StudenGrade>();
StudenGrade grade1 = new StudenGrade
{
CourseID = 1,
Grade = 89,
Student = "A",
};
StudenGrade grade2 = new StudenGrade
{
CourseID = 1,
Grade = 91,
Student = "B",
};
StudenGrade grade3 = new StudenGrade
{
CourseID = 1,
Grade = 90,
Student = "C",
};
StudenGrade grade4 = new StudenGrade
{
CourseID = 2,
Grade = 88,
Student = "A",
};
StudenGrade grade5 = new StudenGrade
{
CourseID = 2,
Grade = 88,
Student = "B",
};
StudenGrade grade6 = new StudenGrade
{
CourseID = 2,
Grade = 80,
Student = "C",
};
all_grades.Add(grade1);
all_grades.Add(grade2);
all_grades.Add(grade3);
all_grades.Add(grade4);
all_grades.Add(grade5);
all_grades.Add(grade6);

List<StudenGrade> grade_course1 =
all_grades.Where(x => x.CourseID == 1).ToList();
List<StudenGrade> grade_course2 =
all_grades.Where(x => x.CourseID == 2).ToList();
StudenGrade top_grade1 =
grade_course1.Where(x => x.Grade >= 90)
.OrderByDescending(x => x.Grade).FirstOrDefault();
if (top_grade1 != null)
Console.WriteLine("Qualified student for CourseID#1 is: " + top_grade1.Student);
if (top_grade1 == null)
{
Console.WriteLine("Input student name to pickup: ");
string pickup_input1 = Console.ReadLine();
if (!string.IsNullOrEmpty(pickup_input1))
Console.WriteLine("Qualified student for CourseID#1 is: " + pickup_input1);
else
Console.WriteLine("No qualified student for CourseID#1!");
}
StudenGrade top_grade2 =
grade_course2.Where(x => x.Grade >= 90)
.OrderByDescending(x => x.Grade).FirstOrDefault();
if (top_grade2 != null)
Console.WriteLine("Qualified student for CourseID#2 is: " + top_grade2.Student);
if (top_grade2 == null)
{
Console.WriteLine("Input student name to pickup: ");
string pickup_input2 = Console.ReadLine();
if (!string.IsNullOrEmpty(pickup_input2))
Console.WriteLine("Qualified student for CourseID#2 is: " + pickup_input2);
else
Console.WriteLine("No qualified student for CourseID#2!");
}
}
My goal is to select the highest grade student from the same CourseID: 1, 2. Only if the highest grade is more than 90; but if none of the students has grade for more than 90, then provide the function (Console.ReadLine()) for user to input student’s name.
With .NET Core Windows Forms designer, I want to use Windows Control for user to pick up the highest score in the same CourseID or not to pickup, just skip to next CourseID students group.
My question is: which Windows Form Control I should use? CheckBox, CheckedListBox, GroupBox?
Since there is not many code example on this topic, please also provide corresponding C# code on how to do the same job as my C# .Net Code.
Thanks,

Continue reading...
 
Back
Top