Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Determine If Row Is Empty in Datagridview

Posted on 2006-11-14
3
Medium Priority
?
197 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 1400 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

704 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