?
Solved

Question about datagridview component in vs 2005

Posted on 2006-06-26
13
Medium Priority
?
808 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
Independent Software Vendors: 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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 …
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 …
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month14 days, 22 hours left to enroll

770 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