Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. try to using datagridview without dataset

try to using datagridview without dataset

Scheduled Pinned Locked Moved Visual Basic
cssdatabasehelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    eyes2007
    wrote on last edited by
    #1

    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...

    J D 2 Replies Last reply
    0
    • E eyes2007

      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...

      J Offline
      J Offline
      John_Adams
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • E eyes2007

        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...

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups