XGuarden
Messages postés259Date d'inscriptiondimanche 14 juillet 2002StatutMembreDernière intervention17 août 2012
-
26 déc. 2006 à 19:49
XGuarden
Messages postés259Date d'inscriptiondimanche 14 juillet 2002StatutMembreDernière intervention17 août 2012
-
27 déc. 2006 à 03:10
Voici 3 semaine que j'ai le meme probleme...
Pour vous expliquer le probleme, je vais le montrer en 3 étapes. Premierement voici une classe de mon programme au complet....
Imports Microsoft.Office.Interop.excel
Public Class TextBoxValidator
Inherits System.Windows.Forms.TextBox
Private cellValidation As Range
Private validatestate As Boolean = False
Private tooltip As New ToolTip
Public ReadOnly Property getState() As Boolean
Get
Return validatestate
End Get
End Property
Public Property ValidationCell() As Range
Get
Return cellValidation
End Get
Set(ByVal cell As Range)
cellValidation = cell
End Set
End Property
Private Sub TextBoxValidator_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.GotFocus
If Me.ForeColor = Color.Gray Then
Me.Clear()
Me.ForeColor = Color.Black
End If
End Sub
Private Sub Text_Validating(ByVal sender As Object, _
ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Validating
If cellValidation.Validation.Value Then
validatestate = True
Me.BackColor = Color.White
Else
validatestate = False
Me.BackColor = Color.Red
tooltip.IsBalloon = True
tooltip.ToolTipIcon = CType(cellValidation.Validation.AlertStyle, ToolTipIcon)
tooltip.ToolTipTitle = cellValidation.Validation.ErrorTitle
tooltip.Show(cellValidation.Validation.ErrorMessage, Me, 2000)
End If
Catch Er As Exception
If Err.Number = 1004 Then
Err.Clear()
Else
MsgBox(Er.Message)
End If
End Try
End Sub
Maintenant voici la ligne de code qui déclannche le probleme de maniere visible
cellValidation.Value = CType(sender, Control).Text
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Il semble que quand je défini la propriété ValidationCell() que j'associe mon controle a la cellule excel corecpondante sans le vouloir.
Voici la seul procédure qui défini la propriété
Private Function GetControl(ByVal cell As Excel.Range) As Control
Dim mycontrol As New Control
Try
Dim text As New TextBoxValidator(cell.Value.ToString)
text.ValidationCell = cell
mycontrol = text
Catch Er As Exception
MsgBox(Er.InnerException)
End Try
Cela fait 3 semaine que je cherche et je n'ai toujours pas réussit a donner la validation a la case sans en meme temps donner une sorte de lien.. SVP j'y comprend rien.