Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Question about datagridview component in vs 2005

Posted on 2006-06-26
13
Medium Priority
?
812 Views
Last Modified: 2008-01-09
I want to know how make an error icon display in the cell of the unbound datagridview.

I've read where this is possible but I can't find code that shows how to make it appear/disappear. I also believw you can set an error tooltip also.

Thanks
Rut
0
Comment
Question by:rutledgj
[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
  • 7
  • 5
13 Comments
 
LVL 12

Expert Comment

by:vb_jonas
ID: 16986992
cell.ErrorText = errorMessage

no?
0
 

Author Comment

by:rutledgj
ID: 16987478
Thanks but I've tried that and I don't see any msg. Also, how do you show the error icon?
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16987700
What is the setting for ShowCellErrors?  If it is set to True, when you set Error text, you should get an icon.

Bob
0
Industry Leaders: 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!

 

Author Comment

by:rutledgj
ID: 16991628
ShowCellError is set to true. Here is the code I'm using:

Private Sub grd1_CellValidating(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellValidatingEventArgs) Handles grd1.CellValidating

        If grd1.IsCurrentCellDirty Then
            grd1.ShowCellErrors = True

            Dim cell As DataGridViewCell
            cell = grd1(e.ColumnIndex, e.RowIndex)
            If IsNumeric(cell.Value) Then
                Exit Sub
            End If
            cell.ErrorText = "Invalid Data"

           
        End If
       

    End Sub
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16995373
What are the cell bounds?  What are the cell icon bounds?

Bob
0
 

Author Comment

by:rutledgj
ID: 16996361
Hey,

    That's why I'm asking the question. I don't know how you do this!
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16996671
How wide is the column?

Bob
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16996685
I see another problem:

  If you are checking grd1.IsCurrentCellDirty, then the data hasn't been saved to the grid yet, and so you can't query the cell for the value with cell.Value.

Bob
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16996697
You need to query cell.EditedFormattedValue instead of cell.Value.

Bob
0
 

Author Comment

by:rutledgj
ID: 16996757
I guess it would be beneficial to maybe see this function coded correctly.  The cells are wide enough to display 5 digits but only 4 is allowed. I'm unsure as to how the error icon is displayed in the cell, if you can position it, or how much wider the cell needs to be to accomadate it.

0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 16996784
Try this:

Private Sub grd1_CellValidating(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellValidatingEventArgs) Handles grd1.CellValidating

        If grd1.IsCurrentCellDirty Then
            grd1.ShowCellErrors = True

            Dim cell As DataGridViewCell = grd1(e.ColumnIndex, e.RowIndex)
            If IsNumeric(cell.EditedFormattedValue) Then
               cell.ErrorText = ""
            Else
               cell.ErrorText = "Invalid Data:  Cell value must be numeric"
            End If
        End If
       
End Sub

Bob
0
 

Author Comment

by:rutledgj
ID: 16996929
so does this allow for room in the cell for the error icon?
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16997307
Yes, since you were never reaching the code that was setting ErrorText, since you were checking cell.Value.  With that code that I showed you, you be able to cell the error icon now.

Bob
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

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…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

596 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