rutledgj
asked on
Question about datagridview component in vs 2005
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
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
ASKER
Thanks but I've tried that and I don't see any msg. Also, how do you show the error icon?
What is the setting for ShowCellErrors? If it is set to True, when you set Error text, you should get an icon.
Bob
Bob
ASKER
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.DataG ridViewCel lValidatin gEventArgs ) 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
Private Sub grd1_CellValidating(ByVal sender As Object, ByVal e As System.Windows.Forms.DataG
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
What are the cell bounds? What are the cell icon bounds?
Bob
Bob
ASKER
Hey,
That's why I'm asking the question. I don't know how you do this!
That's why I'm asking the question. I don't know how you do this!
How wide is the column?
Bob
Bob
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
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
You need to query cell.EditedFormattedValue instead of cell.Value.
Bob
Bob
ASKER
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
so does this allow for room in the cell for the error icon?
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
Bob
no?