Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8736843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:23:02+00:00 2026-06-13T10:23:02+00:00

Using VB.Net I want to make a datagird cell value zero instead of null

  • 0

Using VB.Net

I want to make a datagird cell value zero instead of null

For example

Datagridview1

Id value1 value2 value3

01 null null 0
02 0 null 10
03 100 null 100
...

Expected output

Id value1 value2 value3

01 0 0 0
02 0 0 10
03 100 0 100
...

I have more than 80 columns and 100 rows, instead of checking the cell one by one any other method is available

Tried Code

    Private Sub dataGridView1_CellFormatting(sender As Object, e As DataGridViewCellFormattingEventArgs)
        If e.ColumnIndex = 0 AndAlso e.Value IsNot Nothing Then
            If CInt(e.Value) = 0 Then
                e.Value = ""
            End If
        End If
    End Sub

The above code is not working properly, when i add the details in datagridview from database, showing null cell also.

How to make zero instead of null. Any other method or suggestion

Need VB.Net code help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:23:03+00:00Added an answer on June 13, 2026 at 10:23 am
    • Right-Click the DatagridView and click on Properties.
    • In the Property window, locate DefaultCellStyle
    • Click on the Tab
    • In the Dialog that appear, specify the NullValue

    enter image description here

    You can also set it from code

    dataGridView1.DefaultCellStyle.NullValue = 0;

    Gets or sets the System.Windows.Forms.DataGridView cell display value corresponding
    to a cell value of System.DBNull.Value or null.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

using .NET 3.5. I have a function I want to make multithreaded calls to.
I'm creating a database application using ASP.NET and I want to make a Windows
Using VB.Net I want to get a all datagrid cell values, then insert into
I want to make a chat server by using .NET technology (C# and SQL
I want to make an addin to Windows Explorer toolbar using .NET 4. Can
I'm using asp.net and want to make it possible for the user to set
I want to make Oracle return dates using .NET's Universal Sortable Time format so
I have an Asp.net website using SQL Server. I want to make a website
I'm using Eazfuscator.NET to obfuscate my code.. Now i want to make sure my
I want to make a login system using ASP.NET (MVC). On the internet, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.