witecloner
Well-known member
- Joined
- Feb 12, 2009
- Messages
- 45
- Programming Experience
- Beginner
Hai all, Could any body tell me what's the best method to fill DataGridView DataSource (at least for 1000 record)? Using DataReader or DataSet? if some one know other method please tell me...
Should i use delegate for fill datagridview for multiuser? em...here that's example :
i Have try this code and it's still not to fast when first time loading the data.
Thank's
Should i use delegate for fill datagridview for multiuser? em...here that's example :
VB.NET:
Partial Public Class FormCustomer
Public Delegate Function DelegateData() As BindingSource
Private Function CallBinding() As BindingSource
Try
If SqlConnection1.State = ConnectionState.Closed Then
SqlConnection1.Open()
End If
SqlDataAdapter3.Fill(DataSet2, "Customer")
BindingSource1.DataSource = DataSet2
BindingSource1.DataMember = "Customer"
Return BindingSource1
Catch ex As Exception
MessageBox.Show(ex.ToString, "Error State On : CallBinding() Method", MessageBoxButtons.OK, MessageBoxIcon.Warning)
Return Nothing
Finally
If SqlConnection1 IsNot Nothing Then
SqlConnection1.Close()
End If
End Try
End Function
Public Sub LoadData()
Dim obj_CallBinding As DelegateData
Try
obj_CallBinding = AddressOf CallBinding
Me.DGVCustomer.DataSource = obj_CallBinding.Invoke()
FormatStyle() '--This routine used for format the datagridview style
Catch ex As Exception
MessageBox.Show(ex.ToString, "Error State On : SynchronousData() Method")
End Try
End Sub
Private Sub FormatStyle()
Try
If BindingSource1.Count > 0 Then
With Me.DGVCustomer
.Columns("CustomerUID").Visible = False
.Columns("ContactPerson").Visible = False
.Columns("Jan").Visible = False
.Columns("Feb").Visible = False
.Columns("Mar").Visible = False
.Columns("Apr").Visible = False
.Columns("Mei").Visible = False
.Columns("Jun").Visible = False
.Columns("Jul").Visible = False
.Columns("Agt").Visible = False
.Columns("Sep").Visible = False
.Columns("Okt").Visible = False
.Columns("Nov").Visible = False
.Columns("Des").Visible = False
.Columns("Flag").Visible = False
.Columns("Modified").Visible = False
'Formating Columns and Rows
.Columns("CustomerID").HeaderText = "Customer"
.Columns("CustomerName").HeaderText = "Nama Customer"
.Columns("ParentID").HeaderText = "Konsolidasi"
.Columns("Address").HeaderText = "Alamat"
.Columns("City").HeaderText = "Kota"
.Columns("CustomerID").Width = 75
.Columns("CustomerName").Width = 275
.Columns("ParentID").Width = 75
.Columns("Address").Width = 315
.Columns("City").Width = 145
.Columns("Operator").Width = 75
.ReadOnly = True
.MultiSelect = False
.SelectionMode = DataGridViewSelectionMode.FullRowSelect
.AllowUserToDeleteRows = False
.AlternatingRowsDefaultCellStyle.BackColor = Color.LightYellow
.RowsDefaultCellStyle.ForeColor = Color.Black
End With
End If
Catch ex As Exception
MessageBox.Show(ex.ToString, "Error State On : FormatStyle() Method", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End Try
End Sub
End Class
Public Class FormCustomer
Private Sub FormCustomer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
Me.LoadData()
End Sub
End Class
i Have try this code and it's still not to fast when first time loading the data.
Thank's
Last edited: