1 Using a DataGridView. 2 The DataGridView The DataGridView is a high level control that presents data in a form similar to an Excel spreadsheet. Can.

Slides:



Advertisements
Similar presentations
Holdings Management Overview
Advertisements

Lesson 12 Getting Started with Excel Essentials
Jeopardy Objects Navigation Buttons True/False Parts of a Report Vocabulary Q $100 Q $200 Q $300 Q $400 Q $500 Q $100 Q $200 Q $300 Q $400 Q $500 Final.
Computer Science & Engineering 2111 Text Functions 1CSE 2111 Lecture-Text Functions.
Grading Your Sections Updated 4/14/2011. Grade Collection System Changes Grade entry at any time based on the section’s calendar (beginning/ending dates)
11 Getting Started with ASP.NET Beginning ASP.NET 4.0 in C# 2010 Chapters 5 and 6.
Using FTP Prof. Wayne Pollock Hillsborough Community College Tampa, FL
RETRIEVING DATA FROM FCC LICENSE DATABASE Steps for obtaining query results, and importing it into MS Excel Spreadsheet.
Microsoft Expression Web-Illustrated Unit L: Using Code Tools.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Using Multiple Forms. Creating a New Form ProjectAdd Windows Form.
Tutorial 8 Designing a Web Site with Frames. XP Objectives Explore the uses of frames in a Web site Create a frameset consisting of rows and columns of.
Introduction To Form Builder
1 Chapter 5: Introduction To Form Builder. 2 Forms  Why Do We Use Form Builder?  Why Don’t We Use SQL Only?!
NobleHour Setup Instructions for Students in Courses Requiring Community Site Verification of Service or of Work Spring 2015 For follow-up questions or.
1 Excel Lesson 3 Organizing the Worksheet Microsoft Office 2010 Introductory Pasewark & Pasewark.
BLC Training for Instructors Presented By: Banner Health Learning & Development Team.
The Registration Experience Student Registration via Self-Service.
8 Copyright © 2004, Oracle. All rights reserved. Creating LOVs and Editors.
Copyright © Texas Education Agency, All rights reserved. 1 Web Technologies Website Development with Dreamweaver.
Using Dreamweaver. Slide 1 Dreamweaver has 2 screens that do different things The Document window where you create your WebPages The Site window where.
MBAC 611.  Click on the My Computer Icon  Open your private network directory  Create a new folder named lab7  Copy your lab6 Access file to the lab7.
Programming with Microsoft Visual Basic 2012 Chapter 13: Working with Access Databases and LINQ.
NextGen Trustee Department Disbursements This class will cover the various methods of handling department disbursements. Whether entering them manually.
by Chris Brown under Prof. Susan Rodger Duke University June 2012
Web Technologies Website Development Trade & Industrial Education
1 Lesson 22 Getting Started with Access Essentials Computer Literacy BASICS: A Comprehensive Guide to IC 3, 3 rd Edition Morrison / Wells.
Uploading Image Files. Introduction – Click on Control Panel Button Typically, most instructors will post the majority of their images under the “Course.
Creating a Web Site to Gather Data and Conduct Research.
Website Development with Dreamweaver
Tutorial 8 Designing a Web Site with Frames. XP Objectives Explore the uses of frames in a Web site Create a frameset consisting of rows and columns of.
1 Working with Menus and Dialog Boxes. 2 Objectives You will be able to Create and edit menus for Windows Forms applications. Write code to handle menu.
1 Data Bound Controls II Chapter Objectives You will be able to Use a Data Source control to get data from a SQL database and make it available.
Project 2 Adding Web Pages, Links, and Images Dreamweaver MX 2004 Concepts and Techniques.
The Fundamentals of Using Windows 95. Windows 95 ã operating system that performs every function necessary for the user to communicate and control computer.
Lesson 17 Getting Started with Access Essentials
1 By: Nour Hilal. Microsoft Access is a database software where data is stored in one or more Tables. A Database is a group of related Tables. Access.
1 Scroll Bars Providing Scrollbars. 2 Objectives You will be able to: Use Windows Graphics to display tabular information on a Windows form. Add graphics.
Resetting Student PreTests. Within the MyNursingLab Study Plans, pretests can be taken only one time by the student.
Key Applications Module Lesson 21 — Access Essentials
Working with option button, check box, and list box controls Visual Basic for Applications 13.
 Objectives Objectives  Introduction Introduction  Exploring Excel Exploring Excel  Navigating a Worksheet Navigating a Worksheet  Workbook Workbook.
Chapter 17 Creating a Database.
Week 11 Creating Framed Layouts Objectives Understand the benefits and drawbacks of frames Understand and use frame syntax Customize frame characteristics.
My Worth Calmhey Software Opening Screen My Worth is great at calculating Your Worth. Your Worth is at your finger tips. My Worth is needed for many.
Tutorial 8 Designing a Web Site with Frames. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Explore the uses of frames.
1 Project 7: Northwind Traders Order Entry. 2 Northwind Order Entry Extend the Select Customer program from Project 6 to permit the user to enter orders.
Feedback ELearning in Sakai. Feedback UseExport GradebookWorking in ExcelPost FileView FeedbackUpdate, Download, or Delete.
Unit 5, Lesson 1 Working with Databases. Objectives Identify the parts of the Access screen. Identify the parts of the Access screen. Understand the purpose.
Access Forms and Queries. Entering Data in Your Table  You can add data to your table in Datasheet view, by typing in the columns and rows.  This.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
Creating a Syllabus on the ADX System Created by Larry Rowell and Bill Bolton.
Creating Your First Web Page – Topic: Creating a wiki, blog, image blog and podcast Click Arrow - Next Slide 1.
ASU Rosters for Roster Contacts Class Roster ASR Roster Grade Roster Grade Changes.
Slide 1 of 35 Welcome to GSA’s Vendor and Customer Self Service (VCSS) course Section 3: Basic Navigation This presentation is compliant with section 508.
Chapter 5 Introduction To Form Builder. Lesson A Objectives  Display Forms Builder forms in a Web browser  Use a data block form to view, insert, update,
Chapter 24 I’m Suffering from Information Overload (Access Databases) Clearly Visual Basic: Programming with Visual Basic nd Edition.
Introducing Dreamweaver. Dreamweaver The web development application used to create web pages Part of the Adobe creative suite.
CCA Scheduling Completing CCA Timetabling Template Integrated National Education Information System (iNEIS TM )
1 Project 2: Using Variables and Expressions. 222 Project 2 Overview For this project you will work with three programs Circle Paint Ideal_Weight What.
1111 Creating ASPX Controls Programatically Objectives You will be able to Dynamically add controls to a page. Dynamically alter properties of controls.
Microsoft Office 2013 Try It! Chapter 4 Storing Data in Access.
Computer Literacy BASICS: A Comprehensive Guide to IC 3, 5 th Edition Lesson 18 Getting Started with Excel Essentials 1 Morrison / Wells / Ruffolo.
1 Lesson 18 Getting Started with Excel Essentials Computer Literacy BASICS: A Comprehensive Guide to IC 3, 4 th Edition Morrison / Wells.
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
TechKnowlogy Conference August 2, 2011 Using GoogleDocs for Collaboration.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 11 Creating Web Applications and Writing Data to a Database.
Creating a Presentation
Microsoft Word Illustrated
Using Multiple Forms.
Presentation transcript:

1 Using a DataGridView

2 The DataGridView The DataGridView is a high level control that presents data in a form similar to an Excel spreadsheet. Can be linked to a data source so that it automatically shows whatever is in the source.

3 Example: CSE Schedule We will create a csv file with the schedule for CSE department undergraduate courses using the results of a search in OASIS. Read the file. Store the schedule information in a data structure in memory. Display the information in a DataGridView.

4 Where is the schedule? Ask google!

5 Where is the schedule? Click here

6 Where is the schedule? Click here

7 Fill in Search Criteria

8 Enter search parameters: Term: Spring 2011 Campus: Tampa Department: Engineering Computer Science Level: Undergraduate Status: All Click Search button (near bottom)

9 The Schedule

10 View Source Delete everything except the schedule.

11 Schedule in HTML

12 End of the Schedule

13 Schedule in HTML Replace all instances of with space characters. Save as schedule_2011_spring.html Double click to open file in browser Verify that it looks right. Right click and Open with Excel. Save as CSV schedule_2010_spring.csv Reopen in Excel and Notepad to verify. Note credit hours for Ind Study.

14 Data File The data file can be downloaded from the class web site: Downloads/Schedule_Viewer/ Downloads/Schedule_Viewer/ schedule_2011_spring.csv Download the file to a convenient folder if you have not created it from the web site.

15 Design the Program Create a new Windows forms project. Define a class to hold a schedule entry. Class Schedule_Record Add a DataGridView control to the form. Resize to occupy most of the screen.

16 New Project

17 Add Class

18 The Form Add a DataGridView control to the form. Set its name to dgvSchedule. Anchor on all sides.

19 Implement the Program On Page_Load Read the file. Skip over lines that are not schedule entries. For each schedule entry, create a Schedule_Record object. Add the object to a List. Finally, make the List the DataSource for the DataGridView control. Details on following slides

20 Class Schedule_Record The DataGridView will automatically display all public properties of the objects in its data source. Headings will be the properties’ class names. In class Schedule_Record create an automatic property for each column in the schedule grid. Plus one more, error_detected Downloads/Schedule_Viewer/Schedule_Record.cs

21 Automatic Properties class Schedule_Record { public String session { get; set; } public String college { get; set; } public String department { get; set; } public String reference { get; set; } public String course_number { get; set; } public String section { get; set; } public String course_title { get; set; } public String credit_hours { get; set; } public String permit { get; set; } public String status { get; set; } public String seats_open { get; set; } public String days { get; set; } public String time { get; set; } public String building { get; set; } public String room { get; set; } public String instructor { get; set; } public String campus { get; set; } public String delivery_method { get; set; } public String fees { get; set; } public bool error_detected { get; set; } }

22 Add Constructor Add a constructor for Schedule_Record Take a (csv) string as input. Split the string, creating an array of strings. Set the properties from the array.

23 The Constructor // Constructor public Schedule_Record(String S) { String[] Schedule_Info; Schedule_Info = S.Split(','); if ((Schedule_Info.Length < 19) || (Schedule_Info[1] != "EN")) { error_detected = true; return; } Continued on next slide

24 The Constructor session = Schedule_Info[0]; college = Schedule_Info[1]; department = Schedule_Info[2]; reference = Schedule_Info[3]; course_number = Schedule_Info[4]; section = Schedule_Info[5]; course_title = Schedule_Info[6]; credit_hours = Schedule_Info[7]; permit = Schedule_Info[8]; status = Schedule_Info[9]; seats_open = Schedule_Info[10]; days = Schedule_Info[11]; time = Schedule_Info[12]; building = Schedule_Info[13]; room = Schedule_Info[14]; instructor = Schedule_Info[15]; campus = Schedule_Info[16]; delivery_method = Schedule_Info[17]; fees = Schedule_Info[18]; error_detected = false;

25 Importing the Schedule Now we need to add code to the Page_Load handler to read the file and set up a List of Schedule_Record objects.

26 Importing the Schedule using System; using System.Collections.Generic; using System.Windows.Forms; using System.IO; namespace Schedule_Viewer { public partial class Form1 : Form { List Schedule; public Form1() { InitializeComponent(); import_schedule(); }

27 import_schedule void import_schedule() { StreamReader Reader = null; String input_line; String file_name; Schedule = new List (); file_name Reader = new StreamReader(file_name); if (Reader == null) { MessageBox.Show("Failed to open file " + file_name); return; }

28 import_schedule // Read the schedule file. while ((input_line = Reader.ReadLine()) != null) { Schedule_Record sr = new Schedule_Record(input_line); if (!sr.error_detected) { Schedule.Add(sr); }

29 Setting the DataSource Finally, we need to make the List be the DataSource for the DataGridView: dgvSchedule.DataSource = Schedule;

30 Setting the DataSource Build and run.

31 Program in Action Scroll right.

32 After Scrolling Right

33 Useless Columns Several columns are useless, as every entry has the same value, or they just don’t provide any information: session college department campus delivery_method error_detected

34 Removing Items from the Grid We can remove the useless columns from the DataGridView by making the corresponding properties private.

35 Removing Items from the Grid

36 error_detected Issue We will need an accessor method for error_detected for use by Form1.cs Modify import_schedule to use the function.

37 Program in Action Note that you can resize the columns.

38 Setting the Column Widths We can set the column widths programatically. The DataGridView has a collection of objects that define the columns. Columns property Each object in Columns is of type DataGridViewColumn. Class DataGridViewColumn has a Width property, which we can set. Or we can ask the system to set the width automatically.

39 Setting the Column Widths How do we determine each column's width? Alternative methods: Determine size of strings in the columns. Cut and try. Set the DataGridView's AutoSizeColumnsMode

40 AutoSizeColumnsMode Display the properties of dgvSchedule. Locate AutoSizeColumnsMode Set it to "AllCells"

41 Program Running

42 Avoid Horizontal Scrolling Let’s try to get an entire schedule record to fit on the screen without scrolling in the horizontal direction. Make the form and the DataGridView somewhat wider. Tighten up some columns where the headings are wider than the data. Section Credit_Hours Seats_Open

43 Tighten Up Some Columns public Form1() { InitializeComponent(); import_schedule(); dgvSchedule.DataSource = Schedule; DataGridViewColumnCollection cols = dgvSchedule.Columns; cols[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.None; cols[2].Width = 30; // Section cols[4].AutoSizeMode = DataGridViewAutoSizeColumnMode.None; cols[4].Width = 30; // Credit Hours cols[7].AutoSizeMode = DataGridViewAutoSizeColumnMode.None; cols[7].Width = 30; // Seats Open }

44 Final Result

45 Summary The DataGridView control makes it easy to display tabular data. Properties permit us to control its appearance.