Click here to Skip to main content
15,912,204 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Answercross post - same question in c# forum Pin
Garth J Lancaster7-Jan-10 18:11
professionalGarth J Lancaster7-Jan-10 18:11 
QuestionListView Icons Pin
Crazy Joe Devola7-Jan-10 11:26
Crazy Joe Devola7-Jan-10 11:26 
QuestionVisual Studio 2008 installation question Pin
Central_IT7-Jan-10 3:21
Central_IT7-Jan-10 3:21 
AnswerRe: Visual Studio 2008 installation question Pin
Abhinav S7-Jan-10 3:40
Abhinav S7-Jan-10 3:40 
AnswerRe: Visual Studio 2008 installation question Pin
Dave Kreskowiak7-Jan-10 3:40
mveDave Kreskowiak7-Jan-10 3:40 
AnswerRe: Visual Studio 2008 installation question Pin
Luc Pattyn7-Jan-10 3:53
sitebuilderLuc Pattyn7-Jan-10 3:53 
GeneralRe: Visual Studio 2008 installation question Pin
Abhinav S7-Jan-10 5:12
Abhinav S7-Jan-10 5:12 
QuestionDataSet into DataGridView Pin
spences107-Jan-10 2:03
spences107-Jan-10 2:03 
Hi all,

I have the below code I’m using [in VB.NET 2005] to populate three DataGridView’s I
have on my form without much success at the moment as the DataGridView
only displays one column of data once it has run :/

In the example I am just trying to get it working for one DataGridView
with the intention of passing in SQL to define the DataSet’s once its
working.

I am unsure weather I have missed something because I can view all the
data in the visualiser but it only seems to populate the one column in
the DataGridView.

Please help.

Scott.


      Private Sub cboUserName_SelectedIndexChanged(ByVal sender As System.Object, _
            ByVal e As System.EventArgs) Handles cboUserName.SelectedIndexChanged

            Dim lngUserID As Long

            For i As Integer = 0 To ALWDBDataSet.Tables("tblUser").Rows.Count - 1
                  If ALWDBDataSet.Tables("tblUser").Rows(i).Item("UserName") = cboUserName.Text.ToUpper Then
                        lngUserID = ALWDBDataSet.Tables("tblUser").Rows(i).Item("UserID")
                        Exit For
                  End If
            Next

            '// Initialize a new instance of the OleDbConnection Class
            objConnection = New OleDbConnection(strConncectionString)

            '// Build query string
            Dim strSQL As String = "SELECT * FROM tblUserLogs WHERE UserID = " & lngUserID
            '// Initialize a new instance of the OleDbCommand Class
            objCommand = New OleDbCommand(strSQL, objConnection)

            Call PopulateGrid(dgvLogInfo, "tblUserLogs")

      End Sub


      Private Sub PopulateGrid(ByVal grd As DataGridView, ByVal strTable As String)

            '// Initialize a new instance of the OleDataAdapter class
            objDataAdapter = New OleDbDataAdapter

            '// Initialize a new instance of the DataSet Class
            objDataSet = New DataSet

            '// Set the SelectCommand for the OleDbDataAdapter
            objDataAdapter.SelectCommand = objCommand

            Try
                  '// Poplate the DataSet
                  objDataAdapter.Fill(objDataSet, strTable)

                  '// Bind the DataSet to the DataGrid
                  grd.DataSource = objDataSet
                  grd.DataMember = strTable

                  '// Set the AlternatingRowsDefaultCellStyle.BackColor property
                  grd.AlternatingRowsDefaultCellStyle.BackColor = Color.WhiteSmoke

                  '// Set the CellBorderStyle property
                  grd.CellBorderStyle = DataGridViewCellBorderStyle.None

                  '// Set the SelectionMode property
                  grd.SelectionMode = DataGridViewSelectionMode.FullRowSelect

                  '// Set the AutoSizeColumnsMode property
                  'grd.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells

            Catch OleDbException As OleDbException
                  MessageBox.Show(OleDbException.Message)
            End Try

            '// Cleanup
            objCommand.Dispose()
            objCommand = Nothing
            objDataAdapter.Dispose()
            objDataAdapter = Nothing
            objDataSet.Dispose()
            objDataSet = Nothing
            objConnection.Dispose()
            objConnection = Nothing

      End Sub
AnswerRe: DataSet into DataGridView Pin
Dave Kreskowiak7-Jan-10 3:44
mveDave Kreskowiak7-Jan-10 3:44 
GeneralRe: DataSet into DataGridView Pin
spences107-Jan-10 4:28
spences107-Jan-10 4:28 
GeneralRe: DataSet into DataGridView Pin
Dave Kreskowiak7-Jan-10 4:36
mveDave Kreskowiak7-Jan-10 4:36 
AnswerRe: DataSet into DataGridView [modified] Pin
spences107-Jan-10 4:47
spences107-Jan-10 4:47 
QuestionHow to check if a ListView control has been clicked? Pin
Paul Hasler6-Jan-10 19:05
Paul Hasler6-Jan-10 19:05 
AnswerRe: How to check if a ListView control has been clicked? Pin
Dave Kreskowiak7-Jan-10 0:33
mveDave Kreskowiak7-Jan-10 0:33 
GeneralRe: How to check if a ListView control has been clicked? Pin
Paul Hasler7-Jan-10 3:33
Paul Hasler7-Jan-10 3:33 
GeneralRe: How to check if a ListView control has been clicked? Pin
Dave Kreskowiak7-Jan-10 3:41
mveDave Kreskowiak7-Jan-10 3:41 
AnswerRe: How to check if a ListView control has been clicked? Pin
Luc Pattyn7-Jan-10 3:55
sitebuilderLuc Pattyn7-Jan-10 3:55 
GeneralRe: How to check if a ListView control has been clicked? Pin
Dave Kreskowiak7-Jan-10 4:37
mveDave Kreskowiak7-Jan-10 4:37 
AnswerRe: How to check if a ListView control has been clicked? Pin
DaveAuld7-Jan-10 6:10
professionalDaveAuld7-Jan-10 6:10 
AnswerRe: How to check if a ListView control has been clicked? Pin
Paul Hasler7-Jan-10 15:55
Paul Hasler7-Jan-10 15:55 
QuestionHow to convert open office document to pdf ?? Pin
JC.KaNNaN6-Jan-10 19:03
JC.KaNNaN6-Jan-10 19:03 
AnswerRe: How to convert open office document to pdf ?? [modified] Pin
JC.KaNNaN7-Jan-10 2:12
JC.KaNNaN7-Jan-10 2:12 
QuestionHide a complete row... Pin
MacIntyre6-Jan-10 18:04
MacIntyre6-Jan-10 18:04 
AnswerRe: Hide a complete row... Pin
Dave Kreskowiak7-Jan-10 0:30
mveDave Kreskowiak7-Jan-10 0:30 
QuestionHow to monitor drive activity in vb 2008 Pin
RevEd6-Jan-10 14:21
RevEd6-Jan-10 14:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.