Solved

Determine If Row Is Empty in Datagridview

Posted on 2006-11-14
3
195 Views
Last Modified: 2010-04-23
How do you determine if an entire row is empty?

The code below is not working well.  Even if there is one row of data it has two blocks of text output.

                If IsDBNull(datagrid1.Item(0, r).Value) = False And IsDBNull(datagrid1.Item(1, r).Value) = False And IsDBNull(datagrid1.Item(2, r).Value) = False And IsDBNull(datagrid1.Item(3, r).Value) = False And IsDBNull(datagrid1.Item(4, r).Value) = False Then
                    strTransportSequence &= CurRowStr & "     ==============================" & vbCrLf
                End If



            For r As Integer = 0 To datagrid1.Rows.Count - 1
                Dim CurRowStr As String = ""
                CurRowStr = CurRowStr & "     Test1 : " & datagrid1.Item(0, r).Value & vbCrLf
                CurRowStr = CurRowStr & "     Test2 : " & datagrid1.Item(1, r).Value & vbCrLf
                CurRowStr = CurRowStr & "     Test3 : " & datagrid1.Item(2, r).Value & vbCrLf
                CurRowStr = CurRowStr & "     Test4 : " & datagrid1.Item(3, r).Value & vbCrLf
                CurRowStr = CurRowStr & "     Test5 : " & datagrid1.Item(4, r).Value & vbCrLf
                If IsDBNull(datagrid1.Item(0, r).Value) = False And IsDBNull(datagrid1.Item(1, r).Value) = False And IsDBNull(datagrid1.Item(2, r).Value) = False And IsDBNull(datagrid1.Item(3, r).Value) = False And IsDBNull(datagrid1.Item(4, r).Value) = False Then
                    strTransportSequence &= CurRowStr & "     ==============================" & vbCrLf
                End If
            Next
0
Comment
Question by:endrec
[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 Comments
 
LVL 34

Accepted Solution

by:
Sancler earned 350 total points
ID: 17943032
If I've understood correctly, what you want is this

            For r As Integer = 0 To datagrid1.Rows.Count - 1
                Dim CurRowStr As String = ""
                If IsDBNull(datagrid1.Item(0, r).Value) = False And IsDBNull(datagrid1.Item(1, r).Value) = False And IsDBNull(datagrid1.Item(2, r).Value) = False And IsDBNull(datagrid1.Item(3, r).Value) = False And IsDBNull(datagrid1.Item(4, r).Value) = False Then
                    strTransportSequence &= CurRowStr & "     ==============================" & vbCrLf
                Else
                    CurRowStr = CurRowStr & "     Test1 : " & datagrid1.Item(0, r).Value & vbCrLf
                    CurRowStr = CurRowStr & "     Test2 : " & datagrid1.Item(1, r).Value & vbCrLf
                    CurRowStr = CurRowStr & "     Test3 : " & datagrid1.Item(2, r).Value & vbCrLf
                    CurRowStr = CurRowStr & "     Test4 : " & datagrid1.Item(3, r).Value & vbCrLf
                    CurRowStr = CurRowStr & "     Test5 : " & datagrid1.Item(4, r).Value & vbCrLf
                End If
            Next

Roger
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

734 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