Hi,
I''ve got a databound grid that has an icon set for a combobox cell on validation to indicate an error (the CellTipText is also set). Once the error Icon is set the icon shows up in the cell until the mouse is moved over the cell then the icon is reset to the non-error icon.
I am turning on and off the icon in PrepareViewStyleInfo based on the value of the error message (no error message = normal icon, error message = error icon). The error message isn''t being reset and the code to display the icon in PrepareViewStyleInfo isn''t being called when the icon is reset to the default non-error icon (the CellTipText is still defined).
I''m using a GridBoundColumn to set up the columns of the table in the grid. I suspect that I''m not setting up the column correctly somewhere but I don''t know what to set.
Any help would be appreciated.
Thanks,
Gordon
AD
Administrator
Syncfusion Team
October 19, 2004 05:57 PM UTC
I cannot follow what you are describing.
Is ''error message'' your object, or is it grid.CurrentCell.ErrorMessage? Who should be resetting it?
Maybe if you posted your PrepareViewStyleInfo code and any other snippets, it would make it clearer what you are trying to do.
GR
Gordon Rhea
October 19, 2004 06:07 PM UTC
Private Sub gdbgVerifyIO_PrepareViewStyleInfo(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs) Handles gdbgVerifyIO.PrepareViewStyleInfo
If e.ColIndex = Me.gdbgVerifyIO.Model.NameToColIndex(Me.VERIFYIO_DEF) _
AndAlso Me.gdbgVerifyIO.Model(e.RowIndex, Me.gdbgVerifyIO.Model.NameToColIndex(Me.VERIFYIO_TYPE)).Text.Equals("Input") _
AndAlso Not Me.mblnInUpdate Then
mblnInUpdate = True
If Not mstrErrorText Is Nothing AndAlso mstrErrorText.Length > 0 Then
e.Style.ImageIndex = 1
mstrOldErrorText = mstrErrorText
e.Style.CellTipText = mstrErrorText
Else
e.Style.ImageIndex = 0
mstrOldErrorText = mstrErrorText
e.Style.CellTipText = mstrErrorText
End If
Me.gdbgVerifyIO.Refresh()
mblnInUpdate = False
End If
End Sub
...From the load routine...
Dim gbc2 As New GridBoundColumn
gbc2.MappingName = Me.VERIFYIO_DEF
gbc2.StyleInfo.CellType = "ComboBox"
gbc2.StyleInfo.ChoiceList = Me.mstrcolVerify
gbc2.StyleInfo.ImageList = Me.ilErrorIcons
gbc2.StyleInfo.ImageIndex = 0
Me.gdbgVerifyIO.GridBoundColumns.Add(gbc2)
... From the validation code...
If Me.gdbgVerifyIO.Model(intInputRow, Me.gdbgVerifyIO.Model.NameToColIndex(Me.VERIFYIO_DEF)).CellValue Is Nothing _
OrElse Me.gdbgVerifyIO.Model(intInputRow, Me.gdbgVerifyIO.Model.NameToColIndex(Me.VERIFYIO_DEF)).CellValue Is System.DBNull.Value _
OrElse Me.gdbgVerifyIO.Model(intInputRow, Me.gdbgVerifyIO.Model.NameToColIndex(Me.VERIFYIO_DEF)).Text.Length <= 0 Then
'' we have an error
''mstrOldErrorText = mstrErrorText
mstrErrorText = "Input not specified!"
e.Cancel = True
Else
''mstrOldErrorText = mstrErrorText
mstrErrorText = ""
End If
AD
Administrator
Syncfusion Team
October 19, 2004 08:22 PM UTC
So when you click off the cell that has a wrong value, you want to show an icon until you move the mouse over the cell, and then you want to see an error tip displayed. Is this correct?
Here is a sample that does this. It does this by dynamically subscribing to the cell controls mouseenter and mouseleave events to display a WindowsForms tooltip.
WindowsApplication8_7519.zip
GR
Gordon Rhea
October 20, 2004 12:36 PM UTC
No. I want the error icon to be displayed in the cell until the value is changed. What is happening now is that the error icon is going away as soon as the user moves the mouse over the cell with the error.
I can reset the error message when the cell is changed so that''s not a problem. The problem is that I can''t get the error icon to stay until the cell is changed.
GR
Gordon Rhea
October 20, 2004 01:07 PM UTC
Let me start over and describe the process that''s suposed to happen.
What''s suposed to happen:
When the grid loads it loads all the data except one cell where the user can select from a list of possible values. When the user saves the grid it is validated, if there are errors it will not save. It should replace the icon telling the user to enter data with an error icon. The error icon should remain in the cell until the value is changed at which time the icon should be reset the the default icon.
What is actually happening:
The error icon is being set in validation, but once the user moves the mouse over the cell the icon is being changed back to the default icon even though there is still an error message. I have put a break in the PrepareViewStyleInfo event where I reset the icon to the default (the only place I change the icon is in the PrepareViewStyleInfo event) and it is not executing, but the icon is still being reset. The CellTipText value is not being reset, only the icon.
Hopefully this will help clarify what''s going on.
Gordon
AD
Administrator
Syncfusion Team
October 20, 2004 02:52 PM UTC
I think this is somewhat simpler to handle. You do not have to dynamically subscribe to the cell control mouse events to catch these actions. Here is another little sample. It will mark any non-number in the first column when you click the Validate button. The cell stays marked until you change it.
WindowsApplication9_7453.zip
GR
Gordon Rhea
October 20, 2004 04:20 PM UTC
That took care of it. I just had to set the style right (i was trying to do it using a GridBoundColumn)
Thanks Clay,
Gordon