Solved

VB express 2008. appears handicaped in dealing with grids.

Posted on 2009-05-13
5
254 Views
Last Modified: 2013-12-26
I am having problems getting this information from MS helpers maybe someone here can give me a boost in the right direction.  The application has a function which receives data over a serial port, I want to display the incomming data within a grid, but looking a the toolbox I only see the vb 2008 express datagridviewer control listed.  Since this data is in memory I would like to populate the datagriidviewer one row at a time.  Sounds easy and should be, but the new required codes do not seem to have a method with which I can control where in the grid to place data, namely column and rows. I have seven columns to display for each row.
Something like below should work, but the compiler will not allow this technique.
Any suggestions will be appreciated.  Could it be the express version is cut off at the knees?


FirstGrid = False
        Dim newrow As DataGridView.DataGridViewControlCollection
        newrow.Item
        RowCount = RowCount + 1
        DataGridView1.NewRowIndex
        With DataGridView1
            .CurrentRow = RowCount
            .currentcol = 1
            .CurrentCell = srf
            .currentcol = 2
            .CurrentCell = scol
            .currentcol = 3
            .CurrentCell = srow
            .currentcol = 4
            .CurrentCell = stxt
            .currentcol = 5
            .CurrentCell = asts
            .currentcol = 6
            .CurrentCell = initalarm
            .currentcol = 7
            .CurrentCell = desc
 
        End With

Open in new window

0
Comment
Question by:Jimmyjay21
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 24379969
So you want to be able to specify a Row/Col and place a value there?

This simple examples make a DataTable with 7 columns and 10 rows, then proceeds to fill it up:
Public Class Form1
 
    Private DT As New DataTable()
 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For i As Integer = 1 To 7
            DT.Columns.Add("Column" & i)
        Next
        For i As Integer = 1 To 10
            DT.Rows.Add(DT.NewRow)
        Next
        DataGridView1.DataSource = DT
    End Sub
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        For C As Integer = 1 To DT.Columns.Count
            For R As Integer = 1 To DT.Rows.Count
                DT(R - 1)(C - 1) = "R" & R & "C" & C
            Next
        Next
    End Sub
 
End Class

Open in new window

DataGridViewExample.jpg
0
 

Author Comment

by:Jimmyjay21
ID: 24380150
That's good, and safe, however I need to add several thousand records over a period of 24 hours.
This method will require me to refresh the list evertime a record arrives. I was hoping there might me a method in which I could manually add each record to the grid, bypassing the need to refresh every time a record is received.
I can do this with the list box, however it looks tackey, an organized grid ioffers a much better view.
If not possible I will just have to live with the listbox.
0
 

Author Comment

by:Jimmyjay21
ID: 24380174
Comment was given in previous response.  The solution offered certainly will work and worth the points, before closing I would like to see if the manual process to creating this grid list is possible with VB 2008 express.
Thanks,
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 24380182
What do you mean by "refresh" it everytime...that was merely an example of showing how you can modify a specific row/col...IF IT ALREADY EXISTS.   =)

You can add a NEW row (at any time) to the DATATABLE and it will automatically appear in the DataGridView:



Public Class Form1
 
    Private DT As New DataTable()
 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For i As Integer = 1 To 7
            DT.Columns.Add("Column" & i)
        Next
        DataGridView1.DataSource = DT
    End Sub
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ' ...in response to SOME event...
        Dim dr As DataRow = DT.NewRow
        dr(0) = "Idle"
        dr(1) = "Mind"
        dr(2) = "was"
        dr(3) = "here"
        dr(4) = "with a"
        dr(5) = "datatable/datagrid"
        dr(6) = "example"
        DT.Rows.Add(dr)
    End Sub
 
End Class

Open in new window

0
 

Author Comment

by:Jimmyjay21
ID: 24380974
Whops, that process is what I want to avoid, adding the records to a table is a given, already being done.  Ok I want to move forward with this I will get back ASAP ; but if I am reading this correctly you are saying I only need to add the record to the table and the item will then display without a refresh, I think a refresh will be needed, I'll test to determine what will work.
Thanks.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
clicking a shape in a frame array vb6 3 55
Added a column screws up code 5 78
how to Classify of email (pdf attachments) 7 57
Help with Classic ASP - Parameterizing Query 16 65
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question