try to using datagridview without dataset
-
hi all i m trying to use datagridview to display some data from database and i am trying this with out using dataset. what exactly i m trying is find some alternative from which i can fill datagridview directly with dataadapter or some thing like that. the moral is, i need to done my work (the loading) in just less than a second. does some have any idea thanks in advance.
help everyone Falling down is not defeat...defeat is when u refuse to get up...
-
hi all i m trying to use datagridview to display some data from database and i am trying this with out using dataset. what exactly i m trying is find some alternative from which i can fill datagridview directly with dataadapter or some thing like that. the moral is, i need to done my work (the loading) in just less than a second. does some have any idea thanks in advance.
help everyone Falling down is not defeat...defeat is when u refuse to get up...
Hi, The following code demonstrates one of the ways to fill up DataGridView without using DataSet. BEGIN CODE Imports System Imports System.Drawing Imports System.Windows.Forms Public Class Form1 Inherits System.Windows.Forms.Form Private buttonPanel As New Panel Private WithEvents songsDataGridView As New DataGridView Private WithEvents addNewRowButton As New Button Private WithEvents deleteRowButton As New Button Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load SetupLayout() SetupDataGridView() PopulateDataGridView() End Sub Private Sub songsDataGridView_CellFormatting(ByVal sender As Object, _ ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) _ Handles songsDataGridView.CellFormatting If Me.songsDataGridView.Columns(e.ColumnIndex).Name = _ "Release Date" Then If e IsNot Nothing Then If e.Value IsNot Nothing Then Try e.Value = DateTime.Parse(e.Value.ToString()) _ .ToLongDateString() e.FormattingApplied = True Catch ex As FormatException Console.WriteLine("{0} is not a valid date.", e.Value.ToString()) End Try End If End If End If End Sub Private Sub addNewRowButton_Click(ByVal sender As Object, _ ByVal e As EventArgs) Handles addNewRowButton.Click Me.songsDataGridView.Rows.Add() End Sub Private Sub deleteRowButton_Click(ByVal sender As Object, _ ByVal e As EventArgs) Handles deleteRowButton.Click If Me.songsDataGridView.SelectedRows.Count > 0 AndAlso _ Not Me.songsDataGridView.SelectedRows(0).Index = _ Me.songsDataGridView.Rows.Count - 1 Then Me.songsDataGridView.Rows.RemoveAt( _ Me.songsDataGridView.SelectedRows(0).Index) End If End Sub Private Sub SetupLayout() Me.Size = New Size(600, 500) With addNewRowButton .Text = "Add Row" .Location = New Point(10, 10) End With With deleteRowButton .Text = "Delete Row" .Location = New Point(100, 10) End With With buttonPanel .Controls.Add(addNewRowB
-
hi all i m trying to use datagridview to display some data from database and i am trying this with out using dataset. what exactly i m trying is find some alternative from which i can fill datagridview directly with dataadapter or some thing like that. the moral is, i need to done my work (the loading) in just less than a second. does some have any idea thanks in advance.
help everyone Falling down is not defeat...defeat is when u refuse to get up...
eyes2007 wrote:
i need to done my work (the loading) in just less than a second.
That depends on how much data you're talking about, where the data is stored, what kind of database it is, ..., not to mention that the DGV itself isn't known for it's speed in creating rows.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007