Solved

Working with a data grind in visual studio-Visual Basic 2008 with an SQL 2008 database.

Posted on 2010-11-08
7
350 Views
Last Modified: 2012-05-10
                 Here’s the deal. This is a VB 2008 Windows Application project with an SQL 2008 database, and I am comparing what I can do with a “data grid view”, with what I can do in a “details view” from the data sources.
                  When I use the details view, I notice that the cells are actually text boxes which gives me access to their contents programmatically speaking. I could code in a multiplication function like

Dim Result_A As Integer
Result_A  =  textbox_A.Text * 110
Label_A = Result_A

                   Is there a way for me to get access to the contents of the cells in a row (record) if the view is a Data Grid View, and write functions similar to those in the Details view?                    
0
Comment
Question by:jampost
[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
  • 4
  • 3
7 Comments
 
LVL 7

Expert Comment

by:EYoung
ID: 34089177
Yes.  Here is an example I have used that allows me to retrieve the contents of a particular DGV cell:


    Private Sub dgvMembers_and_Guests_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgvMembers_and_Guests.Click
        'First test for rows present then select the appropriate tab on the form based on the Membership Type
        If dgvMembers_and_Guests.RowCount > 0 Then
            mKey = Trim(dgvMembers_and_Guests.CurrentRow.Cells(0).Value)
            mMember_Type = Trim(dgvMembers_and_Guests.CurrentRow.Cells(1).Value)
            srFill_Screen()
        Else
            mKey = ""
            mMember_Type = ""
            srClear_Screen()
        End If

        btnExit.Focus()
    End Sub


This returns the values of the first and second cells on the current row that the user clicks in the Data Grid View.
0
 

Author Comment

by:jampost
ID: 34089356
EYoung,
      Just wanted to let you know that I am working on this. So far I replaced your dgv name with mine, and I had ti declare mine.  I added:
Dim dgvCreditorAccounts As New dgvCreditorAccounts
Now I have to some how define dgvCreditorAccounts  I admit I am not a pro and I have to research things every now and then.  
 
0
 

Author Comment

by:jampost
ID: 34089395
EYoung,
I am working with Dollars & Cents which means I need the Decimal data type. RowCount is not a member of Decimal. There probably is a way of getting around this though.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Expert Comment

by:EYoung
ID: 34089476
Now sure why you want to use a RowCount as a member of Decimal.  I only use RowCount to confirm that there are rows in the DGV.

You can define a memory variable as a decimal, i.e.
Dim mDecimal_Value As Decimal

Then:
mDecimal_Value = Trim(dgvCreditorAccounts.CurrentRow.Cells(0).Value)
0
 

Author Comment

by:jampost
ID: 34089720
EYoung,
 
As a way of declaring and defining I wrote:
Dim dgvCreditorAccounts As Decimal
If dgvCreditorAccounts .RowCount > 0 Then                  < problem on this line [Rowcount is not a member of Decimal]
Is there another type that will allow 2 decimal places to the right of the decimal point? The data will be money.
0
 
LVL 7

Accepted Solution

by:
EYoung earned 500 total points
ID: 34090426
Are you trying to define your DataGridView control as a decimal value?  If yes, you can't do that.  You need to define the DGV as a DGV and the variable separately as a decimal.  That is why the RowCount is not a member.
0
 

Author Closing Comment

by:jampost
ID: 34091213
Thank you for the help EYoung. I believe I know what to do on this one.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sql2016-WIn10: standard,for SQL servc-account.. 51 44
How can I find this data? 3 31
the way to learn Microsoft BI 13 51
Convert VB web project to C# 3 43
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

696 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