Probleme imcompréensible

XGuarden Messages postés 259 Date d'inscription dimanche 14 juillet 2002 Statut Membre Dernière intervention 17 août 2012 - 26 déc. 2006 à 19:49
XGuarden Messages postés 259 Date d'inscription dimanche 14 juillet 2002 Statut Membre Dernière intervention 17 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

        cellValidation.Value = CType(sender, Control).Text
        Try

            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

        mycontrol.AutoSize = True
        mycontrol.Location = New System.Drawing.Point(0, 0)
        mycontrol.Name = "lblinfo" & index.ToString
        mycontrol.Size = New System.Drawing.Size(80, 20)
        mycontrol.Dock = DockStyle.Fill

        Return mycontrol

    End Function

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.

2 réponses

Utilisateur anonyme
26 déc. 2006 à 21:11
Salut,

La je sais pas si quelqu'un pourras te repondre.
Il faudrais pouvoir tester et debbugger tout ca.
Touve un moyen pour qu'on puissent avoir ton projet.


__________
Kenji
0
XGuarden Messages postés 259 Date d'inscription dimanche 14 juillet 2002 Statut Membre Dernière intervention 17 août 2012
27 déc. 2006 à 03:10
Mon email ces alexqwert55@hotmail.com
suffit de demander=:0)
0
Rejoignez-nous