1. Trang chủ
  2. » Giáo án - Bài giảng

Chapter 8 Implementing Data - Bound Controls

16 331 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 16
Dung lượng 114,88 KB

Nội dung

Chapter 8 Implementing Data-Bound Controls Chapter 8  Lesson 1: Creating a Data-Bound Form with the Data Sources Wizard  Lesson 2: Implementing Data-Bound Controls  Lesson 3: Working with the DataGridView Lesson 1: Creating a Data-Bound Form with the Data Sources Wizard  What is Data-Bound controls? – Bound and Un-Bound mode – Data-bound controls are WinForms controls those can easily bind with data components: DataGrid, ListBox, and a ComboBox – have properties, which you can set as a data component and theyre ready to present your data in WinForms: DataSource,DisplayMember, DataMember. Dataset (Rows) ID, Name… Dataset (Rows) Dataset (Rows) Dataset (Rows) Dataset (Rows) Position??? Lesson 1: Creating a Data-Bound Form with the Data Sources Wizard  DEMO – Creating a Data-Bound Windows Form – Ex p411 BinDingSource  Track record position – MoveNext, MovePrevious…  Change data in datasource – Add, Delete, EndEdit Dataset (Rows) ID, Name… Dataset (Rows) Dataset (Rows) Dataset (Rows) Dataset (Rows) BindinhSource Lesson 2: Implementing Data-Bound Controls  Binding Controls to Data – Simple data binding: displaying a single element  BindingSource productsBindingSource = New BindingSource(NorthwindDataSet1, “Products");  TextBox1.DataBindings.Add("Text", productsBindingSource, "ProductName"); Lesson 2: Implementing Data-Bound Controls  Binding Controls to Data – Complex data binding: binding a control to more than one source of data  BindingSource customersBindingSource=New BindingSource(NorthwindDataSet1, "Customers");  DataGridView1.DataSource = customersBindingSource; – Or  DataGridView1.DataSource = NorthwindDataSet1;  DataGridView1.DataMember = "Customers“; Lesson 2: Implementing Data-Bound Controls  Navigating Records in a DataSet – use a BindingNavigator component. – Assign the BindingNavigator.BindingSource property to BindingSource component Lesson 3: Binding with Listbox/Combobox  Using unBound-mode – Add items manually  Using bound-mode – Single table – Two tables  Core properties – Datasource – DataMember – Displaymember – ValueMember  SeletectedValue – BindingSource – Example Lesson 3: Binding with Listbox/Combobox  Binding with single table – DataSource – DisplayMember – ValueMember  Return value: – SelectedValue Text [...]... Listbox/Combobox Binding with 2 tables – – – DataSource DisplayMember ValueMember Binding with – SelectedValue Lesson 3: Working with the DataGridView Configuring DataGridView Columns Lesson 3: Working with the DataGridView Adding Columns to a DataGridView – Wizard (design time) Adding Columns to a DataGridView (p4 28) – – – – – Dim ProductNameColumn As New DataGridViewTextBoxColumn ProductNameColumn.Name... System.Type.GetType("System.String") DataGridView1.Columns.Add(ProductNameColumn) Lesson 3: Working with the DataGridView Determining the Clicked Cell in DataGridView – use the DataGridView.CurrentCell property Dim CurrentCellValue As String CurrentCellValue = CustomersDataGridView.CurrentCell.Value.ToString Lesson 3: Working with the DataGridView ErrorText proerty of row and cell in row Validating Input in the DataGridView... and cell in row Validating Input in the DataGridView – handle the DataGridView CellValidating event and cancel the edit if the value fails validation (is raised when a cell loses focus.) Lesson 3: Working with the DataGridView Format a DataGridView Using Styles – – DefaultCellStyle AlternatingRowsDefaultCellStyle Lab: Working with the DataGridView – Page 431 . Chapter 8 Implementing Data-Bound Controls Chapter 8  Lesson 1: Creating a Data-Bound Form with the Data Sources Wizard  Lesson 2: Implementing Data-Bound Controls  Lesson. Data-Bound Form with the Data Sources Wizard  What is Data-Bound controls? – Bound and Un-Bound mode – Data-bound controls are WinForms controls those can easily bind with data components: DataGrid,. (Rows) Dataset (Rows) Dataset (Rows) BindinhSource Lesson 2: Implementing Data-Bound Controls  Binding Controls to Data – Simple data binding: displaying a single element  BindingSource productsBindingSource

Ngày đăng: 13/05/2014, 12:19

TỪ KHÓA LIÊN QUAN