[VB.NET] All About the use of dataGridView
in
VB.NET
- on 5:06:00 PM
- No comments
Description
This article we will discuss all about dataGridView in VB.NET, This article may be incomplete because i am just human (Above the sky there is another sky). so i need your help if something usefull about dataGridViewthat's not include in this article. you can add by comment below. if very usefull i will include in this article. many thanks :)
OK, Let's start :
1. i want to make color datagrid, especially column header or row header
----- enableheadersvisualstyles => FALSE
----- to edit color column header you can click on property : columnheadersdefaultcellstyle
----- to edit color row header you can click on property : rowheadersdefaultcellstyle
2. i want to get cell value when row get selected
----- respon the event selected using : SelectionChanged
----- to get row index : dataGridView.CurrentCell.RowIndex
----- to get cell value : dataGridView.Rows(RowIndex).Cells(ColumnIndex).Value()
3. i want every click in dataGridView = click row , not click current cell
----- on property set SelectionMode = fullRowSelect
4. i need to givecell color like white black white black
----- you can goto here dataGridView Color
5. i need filter record in dataGridView without requery
----- you can use bindingSource, but still need current dataSource that you use. here's the example
Dim sourceFilter As New BindingSource()
sourceFilter.DataSource = dataGridView.DataSource 'current data source is exist
sourceFilter.Filter = "[FIELD for FILTER] like '%" & txtFilter.Text & "%'"
dataGridView.Refresh()
6. i want change date format in some column
------ dataGridView.Columns(indexcolumn).DefaultCellStyle.Format = "dd/MM/yyyy"
7. i want color code from HTML
----- colortranslator.fromhtml("#fafafa")
8. i want fit header column
----- autosizecolumnmode = fill
9. i want get value of multiple selection
For Each selectedItem As DataGridViewRow In selectedItems
'Add code to handle whatever you want for each row
msgbox(selectedItem.Index) 'row index
Next
Post a Comment
Harap gunakan bahasa yang baik dan sopan, terima kasih