Drag Drop A File Into TextBox

by a Guest on October 21, 2010 0 Comments

This code snippet shows how to drag and drop a file into a textbox and open the file for reading using the StreamReader class.

Public Class Form1

    Dim txtData As New TextBox()

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        txtData.Dock = DockStyle.Fill
        txtData.Multiline = True
        txtData.AllowDrop = True

        AddHandler txtData.DragDrop, AddressOf txtData_DragDrop
        AddHandler txtData.DragEnter, AddressOf txtData_DragEnter
        Me.Controls.Add(txtData)

    End Sub

    Private Sub txtData_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs)

        If e.Data.GetDataPresent(DataFormats.FileDrop) Then

            Dim Files() As String
            Files = e.Data.GetData(DataFormats.FileDrop)
            Dim sReader As New StreamReader(Files(0))
            txtData.Text = sReader.ReadToEnd()

        End If

    End Sub

    Private Sub txtData_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs)

        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
            e.Effect = DragDropEffects.All
        End If

    End ...

read more

ListView Group Example in Visual Basic

by a Guest on October 21, 2010 0 Comments

This code snippet shows how to add items to groups in a listview control. This example shows how to list drives in groups.

Imports System.IO

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        ListView1.View = View.LargeIcon
        Dim HardDiskGroup As New ListViewGroup("Hard Disk Drives")
        Dim RemovableStorageGroup As New ListViewGroup("Devices with Removable Storage")
        ListView1.Groups.Add(HardDiskGroup)
        ListView1.Groups.Add(RemovableStorageGroup)

        For Each DInfo In DriveInfo.GetDrives()

            If DInfo.DriveType = DriveType.Fixed Then
                Dim Item As New ListViewItem()
                Item.Text = DInfo.Name
                Item.Group = HardDiskGroup
                ListView1.Items.Add(Item)
            ElseIf DInfo.DriveType = DriveType.CDRom Then
                Dim Item As New ListViewItem()
                Item.Text = DInfo.Name
                Item.Group = RemovableStorageGroup
                ListView1.Items.Add(Item)
            End If

        Next

    End Sub

End Class
 

Semi Transparent Panel

by a Guest on October 21, 2010 0 Comments

This snippet shows how to develop a custom panel which is semi transparent by overriding CreateParams and the OnPaint method of the Panel control.

Imports System.Windows.Forms

Public Class xPanel
    Inherits Panel

    Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
        Get
            Dim cp As CreateParams
            cp = MyBase.CreateParams
            cp.ExStyle = &H20
            Return cp
        End Get
    End Property

    Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
        e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(128, 0, 0, 0)), Me.ClientRectangle)
    End Sub

    Protected Overrides Sub OnSizeChanged(ByVal e As System.EventArgs)
        MyBase.OnSizeChanged(e)
    End Sub
End Class
 

Nivo Slider is One Awesome jQuery Image Slider

by a Guest on October 3, 2010 0 Comments

Nivo Slider is the most awesome jQuery image slider, manual and auto slide transaction with cool effect. jqFancyTransitions is easy-to-use jQuery plugin for displaying your photos as slideshow with fancy transition effects.

Nivo Slider Home Page

Will Microsoft SQL Server Ever Pass Oracle?

by a Guest on August 16, 2010 0 Comments

Do you think that Microsoft SQL Server will ever pass Oracle?

Page 1 of 1.

Post categories

Post archives