Tải bản đầy đủ (.pptx) (36 trang)

Lesson 3 Data binding

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (240.09 KB, 36 trang )

Chapter 3
Binding, linking, update data in a disconnected
environment
Lesson 3: Data binding













 !
Contents
Slide 2

Data binding !conneconcontroldata

"#$%%%


$&#%

'"!"$%
#%!&
What is data binding?


Slide 3
What is data binding? (cont.)
Slide 4
TextBox
DataTable
Update from textbox to DataTable
dataTable.Rows[0][“MaSV”] = textbox.Text;
Set textbox value from DataTable
textbox.Text = dataTable.Rows[0][“MaSV”];
TextBox
DataTable
Data Binding

#!

(!!%

#"#!)*++$,$-+$./$0

-#!+

#(#!!%"

#"#!+),+$-#+$$0
Types of data binding
Slide 5














 !
Contents
Slide 6

!!%#)$
!%#$#$

#),$*++$/$-+$./$,+$
-#+$$0



#)*#$'#,$0
Bound-control and unbound-control
Slide 7














 !
Contents
Slide 8

!!%#)

)

-

-

1#)##
Binding data to controls using DataBinding property
Slide 9
ControlName.DataBindings.Add( propertyName, DataSource, FieldName )
- !!%#
,$*++$/0 2*+2
-+$./$0 2-2
-#+$,+$0 22

3+#!4)
()

5DataBindings5678*+9$5*:89;$89<=
>5DataBindings5678-9$5*:89;$8>9<=

3+#!?)
()
@7$22<=
5DataBind ings5678*+9$$89<=
>5DataBindings5678-9$$8>9<=
Example
Slide 10

)

!%##

!!%

3+#!)
A*5@5*:89;=
A*5!%#@8*9=
A*5#@89=
Binding data to ListBox, ComboBox
Slide 11
ListBox1.DataSource = DataTable object;
ListBox1.DisplayMember = FieldName;
ListBox1.ValueMember = FieldName;

)

*



Binding data to DataGridView, GridView
Slide 12
DataGridView1.DataSource = dataset;
DataGridView1.DataMember = "TableName";
DataGridView1.DataSource = datatable;
BindingSource bs = new BindingSource(dataset, "TableName");
DataGridView1.DataSource = bs;
Example: ComboBox, DataGridView
See more Module 14, Exercise
4
Slide 13













 !
Contents
Slide 17
Working with the DataGridView (p.425)


-(#

6#

#

#

!

1#%
Slide 18

*+%!"#
Configuring DataGridView columns
Slide 19
Column Type Description
DataGridViewTextBoxColumn Use this column type to display text and numeric values
DataGridViewCheckBoxColumn Use this column to display Boolean values
DataGridViewImageColumn Use this column to display images
DataGridViewButtonColumn Use this column to provide users with a button control
DataGridViewComboBoxColumn Use this column type to present lists of choices
DataGridViewLinkColumn Use this column type to display links to other data

6#

smart tag "

6#!##%

*++-#@*++-#7<=
5#@2>#2=
5A*+@2>#2=
5*%!@%#5*%!5*%!72%#52<=
45-#567<=
Adding Columns to a DataGridView
Slide 20

#

smart tag "

6#!##%

-Remove#!#"#

3+#!)
45-#5.#72>#2<=
Deleting columns in the DataGridView
Slide 21

*#$datagridView.CurrentCell.Value

@45--55*7<=

*%$datagirdView[int columnIndex, int rowIndex].Value

*+"#$datagridView.CurrentCell.ColumnIndex$
datagridView.CurrentCell.RowIndex


*$--
Determining the clicked cell in DataGridView
Slide 22
private void dgvSV_CellClick( object sender, DataGridViewCellEventArgs e )
{

// using e to define column and row index of current cell
}

ACellValidang

-"

B-""
!C-7$
-36<D
"75-#:5-#'+;5#5*!!7<@@2>.E-*632<
D
"751#/5*7<5*#7<@@22< D
5.:5.'+;53*+@2>#F2=
5-@=
G
 
5.:5.'+;53*+@22= 
G
G
Validating input in the DataGridView
Slide 23

"-%!!%


6."-%!!%
Format a DataGridView using Styles
Slide 24









-



 !
Contents
Slide 25

-



(


Creating and using DataView object
Slide 26


*#H"*

)



$($$$

-)

@7<=

@7*<=

-"+

3%*"

@5*:2-#2;5"=
Creating DataView object (p.396)
Slide 27



3+#!)5@=

!%#.*++$,$,$0

".!*

View data using a DataView (p.397)
Slide 28

Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×