Results 1 to 2 of 2

Thread: DefaultCellStyle.NullValue or setting standard error graphic to Bitmap

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2013
    Location
    Newcastle, Australia
    Posts
    158

    DefaultCellStyle.NullValue or setting standard error graphic to Bitmap

    i have a databound DGV and need to replace the standard error graphic to my own Image so when the user clicks add new the ugly red cross icons do not show

    i have read the info on MSDN and done some google searches as well as a lot of playing around with code but cant seem to get it to work


    Source for this http://msdn.microsoft.com/en-AU/libr...=vs.85%29.aspx
    So this is what i can understand so far and what i have tried

    according to MSDN to change the standard error image you set the DataGridViewCellStyle.NullValue property for this cell style object to a null reference

    So i tried

    Code:
    ProfilesDataGridView.DefaultCellStyle.NullValue = vbNull
    However i get this error


    the following exception occured in the datagridview:

    system.formatException: Formated value of the cell has wrong type
    BUT all that just disables the standard error image i think?

    I need to know how to change the image from icon to bitmap so i can use my own png image.

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: DefaultCellStyle.NullValue or setting standard error graphic to Bitmap

    Think you need to read a bit more carefully .....

    To prevent the standard error graphic from appearing for a null reference (Nothing in Visual Basic) or DBNull.Value cell values, set the DataGridViewCellStyle.NullValue property for this cell style object to a null reference (Nothing in Visual Basic) or your own error graphic before adding rows to the control. This does not affect the row for new records, however. To prevent the error graphic from appearing in the row for new records when the control AllowUserToAddRows property value is true, you must also either explicitly set the cell value to a null reference (Nothing in Visual Basic) or your own error graphic in a handler for the control RowsAdded event or set the column CellTemplate property to an instance of a DataGridViewImageCell-derived type with an overridden DefaultNewRowValue property that returns a null reference (Nothing in Visual Basic) or your own error graphic.
    If the NullValue property of the object returned by the DefaultCellStyle property has a value equal to the standard error graphic of type Bitmap, changing the ValuesAreIcons property value to true automatically sets NullValue to the standard error graphic of type Icon. If NullValue has a value equal to the standard error graphic of type Icon, changing the ValuesAreIcons property value to false automatically sets NullValue to the standard error graphic of type Bitmap.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width