Les Snippets

Connexion

Faire des boites de dialogues complêtes

Niveau requis pour utiliser/comprendre cette source : 1 ( Débutant )
Créé le 05/06/2006 13:24:24 et initié par romagny13 [Liste]
Date de mise à jour : 05/06/2006 18:00:48
Vue : 11348
Catégorie(s) : WinForm
Langages dispo pour ce code :
- VB 2005, VB.NET 1.x
- Windev
- Delphi 5
- Voir tous les langages pour ce code snippet



Langage : VB.NET 1.x , VB 2005
Date ajout : 05/06/2006
Posté par romagny13 [Liste]
DateMAJ : 05/06/2006

OPENFILEDIALOG
Try
            With odlgTextFile
                .CheckFileExists = True
                .CheckPathExists = True
                .DefaultExt = "txt"
                .DereferenceLinks = True
                .Filter = "Text files (*.txt)|*.txt|All files|*.*"
                .Multiselect = False
                .RestoreDirectory = True
                .ShowHelp = True
                .ShowReadOnly = False
    .ReadOnlyChecked = False
                .Title = "Select a file to open"
                .ValidateNames = True
If .ShowDialog = Windows.Forms.DialogResult.OK Then
                    Try
                    Catch fileException As Exception
                        Throw fileException
                    End Try
                End If
            End With
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, Me.Text)
        End Try



SAVEFILEDIALOG

Try
            With sdlgTextFile
                .AddExtension = True
                .CheckPathExists = True
                .CreatePrompt = False
                .OverwritePrompt = True
                .ValidateNames = True
                .ShowHelp = True
                .DefaultExt = "txt"
                .FileName = filename
                .Filter = _
                "Text files (*.txt)|*.txt|" & _
                "All files|*.*"
                .FilterIndex = 1
                If .ShowDialog() = Windows.Forms.DialogResult.OK Then
                End If
            End With
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, Me.Text)
        End Try
COLORDIALOG
   Static CustomColors() As Integer = _
         {RGB(255, 0, 0), RGB(0, 255, 0), RGB(0, 0, 255)}
        Try
            With cdlgText
                .Color = txtFileContents.ForeColor
                .CustomColors = CustomColors
                .AllowFullOpen = True.
                .AnyColor = True
                .FullOpen = False
                .SolidColorOnly = True
                .ShowHelp = True
                If .ShowDialog() = Windows.Forms.DialogResult.OK Then
                    txtFileContents.ForeColor = .Color
                    ' Store the custom colors for future use. 
                    CustomColors = .CustomColors
                End If
                cdlgText.Reset()
            End With
            'With cdlgText
            '  .Color = txtFileContents.ForeColor
            '  If .ShowDialog() = DialogResult.OK Then
            '    
            '  End If
            'End With
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, Me.Text)
        End Try
FONTDIALOG
Try
            With fdlgText
                .Font = txtFileContents.Font
                .Color = txtFileContents.ForeColor
                .ShowColor = True
                .ShowApply = True
                .ShowEffects = True
                .ShowHelp = True
                .AllowScriptChange = True
                .AllowSimulations = False
                .AllowVectorFonts = False
                .AllowVerticalFonts = False
                .FixedPitchOnly = False
                .FontMustExist = True
                .MaxSize = 48
                .MinSize = 8
                If .ShowDialog = Windows.Forms.DialogResult.OK Then
                    txtFileContents.Font = .Font
                End If
            End With
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, Me.Text)
        End Try
EPLORATEUR WINDOWS DE DOSSIERS (PETITE FENETRE CARREE)
Try
            With fldlgList
                .RootFolder = Environment.SpecialFolder.Personal
                .Description = "Select the directory you want to use as the default."
                .ShowNewFolderButton = True
                If .ShowDialog = Windows.Forms.DialogResult.OK Then
                    'txtDirectory.Text = .SelectedPath
                End If
            End With
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, Me.Text)
        End Try
EXPLORATEUR WINDOWS DE FICHIERS ET DOSSIERS
Try
            With odlgFileNames
                .Reset()
                .InitialDirectory = My.Computer.FileSystem.SpecialDirectories.Temp
                .AddExtension = True
                .CheckFileExists = True
                .CheckPathExists = True
                .DefaultExt = "txt"
                .DereferenceLinks = True
                .Filter = _
                "Text files (*.txt)|*.txt|" & _
                "All files|*.*"
                .Multiselect = True
                .RestoreDirectory = True
                .ShowHelp = True
                .ShowReadOnly = False
                .Title = "Select a file"
                .ValidateNames = True
                If .ShowDialog() = Windows.Forms.DialogResult.OK Then
                    lstFiles.DataSource = .FileNames
                    'Dim strName As String
                    'For Each strName In .FileNames
                    '    lstFiles.Items.Add(strName)
                    'Next
                End If
            End With
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, Me.Text)
        End Try


Snippets en rapport avec : Openfiledialog, Savefiledialog, Colordialog, Fontdialog, Explorateur



Codes sources en rapport avec : Openfiledialog, Savefiledialog, Colordialog, Fontdialog, Explorateur

{PHP} EXPLORATEUR FTP SUR 2 NIVEAUX
Une petit source qui peut aider certains à comprendre l'utilisation des dossiers. Moi-même je vie...

{Visual Basic, VB6, VB.NET, VB 2005} JEU DE WUMPUS BASIC EN VB6
Une grille 6X6 cache un monstre(wumpus) un trésor et 4 sables mouvants dont les positions sont génér...

{Visual Basic, VB6, VB.NET, VB 2005} [VB6] YMXPLORER : DOUBLE EXPLORATEUR DE FICHIERS
Double explorateur de fichiers, DragDrop dans les MSHFlexGrid, Fonctions de remplacement (voir ma ...

{Visual Basic, VB6, VB.NET, VB 2005} EXPLORATEUR TREEVIEW AVEC CHECKBOXES ET IMAGES
Bonjour les codeurs, Alors voici ma première source que je poste. (codé avec VB.Net 2005) La c...

{Visual Basic, VB6, VB.NET, VB 2005} YOMMEXPLORER AUGMENTÉ
Les ajouts ont été faits sur la source originale de http://www.vbfrance.com/code.aspx?ID=42960, et s...

{C# / C#.NET} EXTRACTION DES MINIATURES DES FICHIERS (COMME DANS L'EXPLORATEUR MODE DÉTAILS)
Ce code permet d'extraire les miniatures des fichiers comme en mode Détails de l'explorateur Windows...

{Javascript / DHTML} EXPLORATEUR WEB
Bonjour à tous, Cette source n'a pas pour but de vous fournir un explorateur digne de nom mais a ...

{PHP} B0T, UNE SOURCE QUI VOUS PERMET DE VISUALISER LE CONTENU DE VOTRE TABLE MYSQL OU SQL SERVER
Un petit code qui permet de visualiser votre table en vous logant simplement !! Je suis en SQL SERV...

{Delphi} EXPLORATEUR
c'est un programme pour explorer le fichiers codé en dephi 6 c'est ma premier source sur cette cett...

{PHP} EXPLORATEUR DE FICHIER PHP
Un petit explorateur de fichier en php Je trouve qu'il est pratique je l'utilise assez souvent ...