xrjf 230 Posting Whiz

Thanks to you again for your confidence.

xrjf 230 Posting Whiz

Well, both tables must be read. You may code something like:

    Public Sub Displayitem()

        Dim cmd As New OleDb.OleDbCommand("SELECT * FROM pur_inv,inv_type WHERE pur_inv.invtypid=inv_type.invtypid ORDER BY purinvdt", cn)
        Dim dr As OleDb.OleDbDataReader = cmd.ExecuteReader()

        ListView1.Items.Clear()
        Do While dr.Read()
            Dim new_item As New  _
                     ListViewItem(dr.Item("purinvdt").ToString)
            new_item.SubItems.Add(dr.Item("purinvid").ToString)
            new_item.SubItems.Add(dr.Item("prtid").ToString)

            new_item.SubItems.Add(dr.Item("pur_inv.invtypid").ToString)
            new_item.SubItems.Add(dr.Item("taxamt").ToString)
            new_item.SubItems.Add(dr.Item("tottaxblamt").ToString)
            new_item.SubItems.Add(dr.Item("invamt").ToString)
            ListView1.Items.Add(new_item)
        Loop
    End Sub
xrjf 230 Posting Whiz

Then change invtypid by invtyp:

Public Sub Displayitem()
        ListView1.Items.Clear()
        Dim cmd As New OleDb.OleDbCommand("SELECT * FROM pur_inv ORDER BY purinvdt", cn)
        Dim dr As OleDb.OleDbDataReader = cmd.ExecuteReader()

        Do While dr.Read()
            Dim new_item As New  _
     ListViewItem(dr.Item("purinvdt").ToString)
            new_item.SubItems.Add(dr.Item("purinvid").ToString)
            new_item.SubItems.Add(dr.Item("prtid").ToString)

            new_item.SubItems.Add(dr.Item("invtyp").ToString)
            new_item.SubItems.Add(dr.Item("taxamt").ToString)
            new_item.SubItems.Add(dr.Item("tottaxblamt").ToString)
            new_item.SubItems.Add(dr.Item("invamt").ToString)
            ListView1.Items.Add(new_item)
        Loop
    End Sub
xrjf 230 Posting Whiz

Of course, if not present, you should add a reference to System.Linq.

xrjf 230 Posting Whiz

If you mean to select a concrete id, you could do the following. When invtypid is -1, all the ids will be shown (on load event); when > -1 that only id will be shown (when button is clicked):

    Public Sub Displayitem(Optional invtypid As Int32 = -1)

        Dim da As New OleDbDataAdapter("SELECT * FROM pur_inv ORDER BY purinvdt", cn)
        Dim ds As New DataSet
        da.Fill(ds, "myTable")
        Dim dt As DataTable = ds.Tables("myTable")

        Dim q() As DataRow
        If invtypid = -1 Then
            q = (From r In dt.AsEnumerable Select r).ToArray
        Else
            q = (From r In dt.AsEnumerable _
                 Where r.Item("invtypid") = invtypid _
                 Select r).ToArray
        End If

        ListView1.Items.Clear()
        For Each dr As DataRow In q
            Dim new_item As New  _
                 ListViewItem(dr.Item("purinvdt").ToString)
            new_item.SubItems.Add(dr.Item("purinvid").ToString)
            new_item.SubItems.Add(dr.Item("prtid").ToString)

            new_item.SubItems.Add(dr.Item("invtypid").ToString)
            new_item.SubItems.Add(dr.Item("taxamt").ToString)
            new_item.SubItems.Add(dr.Item("tottaxblamt").ToString)
            new_item.SubItems.Add(dr.Item("invamt").ToString)
            ListView1.Items.Add(new_item)
        Next
    End Sub
xrjf 230 Posting Whiz

I can't see anything wrong with the code you are sharing. So, what's the problem? Can you explain a bit further?

xrjf 230 Posting Whiz

Just a file system filter driver Here would do the job.

rproffitt commented: Should be interesting to see Mr.M's take on this answer. Good find. +12
xrjf 230 Posting Whiz

You may send the image as plain text Click Here

xrjf 230 Posting Whiz

Thank you for your confidence.

xrjf 230 Posting Whiz

Sorry, I thought your code was for WPF. So, it should be:

    Public Sub listView1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles ListView1.KeyDown
        If e.Modifiers = Keys.Alt AndAlso _
        e.KeyCode = Keys.Delete Then
            If ListView1.SelectedItems.Count Then
                Dim item As ListViewItem = ListView1.SelectedItems(0)
                ListView1.Items.Remove(item)
                e.Handled = True
            End If
        End If
    End Sub
xrjf 230 Posting Whiz

I would code this way:

    Public Sub listView1_KeyDown(sender As Object, e As System.Windows.Input.KeyEventArgs) Handles ListView1.KeyDown
        If e.Key = Key.System AndAlso _
        e.SystemKey = Key.Delete Then
            If ListView1.SelectedItems.Count Then
                Dim item As ListViewItem = ListView1.SelectedItems(0)
                ListView1.Items.Remove(item)
                e.Handled = True
            End If
        End If
    End Sub
xrjf 230 Posting Whiz

Are you talking about a ListView, a container of images? Or perhaps are you refering to a listbox filled with items?

xrjf 230 Posting Whiz

For example:

    Enum mouseDwn
        none = 0
        srcIsNum1
        srcIsNum2
    End Enum
    Dim IsMouseDown As mouseDwn = mouseDwn.none
    Private Sub DataGridView1_CellMouseDown(sender As Object, e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseDown
        IsMouseDown = mouseDwn.srcIsNum1
    End Sub
    Private Sub DataGridView2_CellMouseDown(sender As Object, e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView2.CellMouseDown
        IsMouseDown = mouseDwn.srcIsNum2
    End Sub
    Private Sub DataGridView2_CellMouseMove(sender As Object, e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView2.CellMouseMove
        If IsMouseDown = mouseDwn.srcIsNum2 Then
            With DataGridView2
                .DoDragDrop(CStr(.Rows(e.RowIndex).Cells(e.ColumnIndex).Value), DragDropEffects.Copy)
                IsMouseDown = mouseDwn.none
            End With
        End If
    End Sub
    Private Sub DataGridView1_CellMouseMove(sender As Object, e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseMove
        If IsMouseDown = mouseDwn.srcIsNum1 Then
            With DataGridView1
                .DoDragDrop(CStr(.Rows(e.RowIndex).Cells(e.ColumnIndex).Value), DragDropEffects.Copy)
                IsMouseDown = mouseDwn.none
            End With
        End If
    End Sub
    Private Sub DataGridView1_DragEnter(sender As Object, e As System.Windows.Forms.DragEventArgs) Handles DataGridView1.DragEnter
        If e.Data.GetDataPresent(DataFormats.Text) AndAlso _
        IsMouseDown = mouseDwn.srcIsNum2 Then
            e.Effect = DragDropEffects.Copy
        Else
            e.Effect = DragDropEffects.None
        End If
    End Sub
    Private Sub DataGridView2_DragEnter(sender As Object, e As System.Windows.Forms.DragEventArgs) Handles DataGridView2.DragEnter
        If e.Data.GetDataPresent(DataFormats.Text) AndAlso _
        IsMouseDown = mouseDwn.srcIsNum1 Then
            e.Effect = DragDropEffects.Copy
        Else
            e.Effect = DragDropEffects.None
        End If
    End Sub
    Private Sub DataGridView1_DragDrop(sender As Object, e As System.Windows.Forms.DragEventArgs) Handles DataGridView1.DragDrop
        Try
            Dim row, col As Integer
            getRowAndColumn(sender, row, col, e)
            DataGridView1.Rows(row).Cells(col).Value = e.Data.GetData(DataFormats.Text)
        Catch ex As Exception
        End Try
    End Sub
    Private Sub DataGridView2_DragDrop(sender As Object, e As System.Windows.Forms.DragEventArgs) Handles DataGridView2.DragDrop
        Try
            Dim row, col As Integer
            getRowAndColumn(sender, row, col, e)
            DataGridView2.Rows(row).Cells(col).Value = e.Data.GetData(DataFormats.Text)
        Catch ex As Exception
        End Try
    End Sub
    Sub getRowAndColumn(sender As Object, ByRef row As Int32, ByRef col As Int32, e As System.Windows.Forms.DragEventArgs)
        With DataGridView1
            Dim grvScreenLocation As Point = sender.PointToScreen(sender.Location)
            Dim tempX As …
xrjf 230 Posting Whiz

On the mouse down event for each source, while initiating the drag, you may set a flag IsMouseDown with a value indicating which is the source. If the mouse down event occurs in let's say DataGridView1, then set IsMouseDown=srcIsNum1. In case the dragging starts with a mouse down event on a cell (or row, column, ...) of DataGridView2, set IsMouseDown=srcIsNum2. Of course flag IsMouseDown can be a class instance and contain much more information; not only the source, but the row, column, or any required data.

    Enum mouseDwn
        srcIsNum1
        srcIsNum2
    End Enum
    Dim IsMouseDown As mouseDwn
xrjf 230 Posting Whiz

If product names are really the same in both datagridview, i.e., no need to add rows:

    Dim us As New Globalization.CultureInfo("en-US")
    Function parseN(value As String, ByRef result As Double) As Boolean
        Return Double.TryParse(value, Globalization.NumberStyles.Any, us, result)
    End Function

    Private Sub btnCopyLeftToRight_Click(sender As System.Object, e As System.EventArgs) Handles btnCopyLeftToRight.Click
        CopyDGV(DataGridViewLeft, DataGridViewRight)
    End Sub
    Private Sub btnCopyRightToLeft_Click(sender As System.Object, e As System.EventArgs) Handles btnCopyRightToLeft.Click
        CopyDGV(DataGridViewRight, DataGridViewLeft)
    End Sub
    Sub CopyDGV(source As DataGridView, destination As DataGridView)
        Try
            With source
                Dim colChk As Int32 = -1
                For col As Int32 = 0 To .Columns.Count - 1
                    If .Columns(col).GetType Is GetType(DataGridViewCheckBoxColumn) Then
                        colChk = col
                        Exit For
                    End If
                Next
                If colChk = -1 Then
                    MessageBox.Show("Found no checkbox column.")
                    Exit Sub
                End If
                Dim vcolNames() As String = {"p_code", "deal_price", "unit_price", "unit_amt"}
                Dim vcolIndex() As Int32 = {-1, -1, -1, -1}
                For col As Int32 = 0 To .Columns.Count - 1
                    Dim colName As String = LCase(.Columns(col).Name)
                    Dim pos As Int32 = Array.IndexOf(vcolNames, colName)
                    If pos > -1 Then
                        vcolIndex(pos) = col
                    End If
                Next
                For i As Int32 = 0 To vcolIndex.Length - 1
                    If vcolIndex(i) = -1 Then
                        MessageBox.Show("Found no source column for " + vcolNames(i))
                        Exit Sub
                    End If
                Next
                For row As Int32 = 0 To .Rows.Count - 1
                    Dim chk As DataGridViewCheckBoxCell = .Rows(row).Cells(colChk)
                    If chk.Value Then
                        ' verify p_code:'
                        Dim pcode = .Rows(row).Cells(vcolIndex(0)).Value
                        If pcode Is DBNull.Value Then
                            MessageBox.Show("Source p_code is null at line #" + (row + 1).ToString)
                            Exit Sub
                        End If
                        Dim pCodeB = destination.Rows(row).Cells(vcolIndex(0)).Value
                        If …
xrjf 230 Posting Whiz

That's a good new. Anyway, running several times the application seems that easily there may be duplicated table names, but I imagine you already have consider it.

xrjf 230 Posting Whiz

Let's imagine population is done so there is code, product, units, price, discount and amount.
Probably you'll need to calculate the amount by clicking the 'update amount' button:

    Private Sub DataGrid_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        DataGridView1.ColumnCount = 6
        DataGridView1.Columns(0).Name = "Code"
        DataGridView1.Columns(1).Name = "Product"
        DataGridView1.Columns(2).Name = "Units"
        DataGridView1.Columns(3).Name = "Price"
        DataGridView1.Columns(4).Name = "Discount"
        DataGridView1.Columns(5).Name = "Amount"

        Dim row As String()
        row = New String() {"3", "Product A", "100", "5.5", "0.0", "0"}
        DataGridView1.Rows.Add(row)
        row = New String() {"5", "Product B", "20", "15.0", "3.0", "0"}
        DataGridView1.Rows.Add(row)
        row = New String() {"6", "Product C", "300", "2.5", "5.0", "0"}
        DataGridView1.Rows.Add(row)
        row = New String() {"8", "Product D", "70", "10", "0.0", "0"}
        DataGridView1.Rows.Add(row)
        DataGridView1.Columns(0).Visible = False

        Dim btn As New DataGridViewButtonColumn()
        DataGridView1.Columns.Add(btn)
        btn.HeaderText = "Update"
        btn.Text = "Update Amount"
        btn.Name = "btnUpdate"
        btn.UseColumnTextForButtonValue = True

    End Sub
    Function parseNum(value As String) As Double
        Static us As New Globalization.CultureInfo("en-US")
        Dim dbl As Double
        Double.TryParse(value, _
            Globalization.NumberStyles.Any, us, dbl)
        Return dbl
    End Function
    Dim us As New Globalization.CultureInfo("en-US")
    Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
        Try
            With DataGridView1
                If .Columns(e.ColumnIndex).Name = "btnUpdate" Then ' update button pressed
                    Dim units, price, discount, amount As Double
                    Dim colAmount As Int32
                    For i = 0 To .Columns.Count - 1
                        Dim value = .Rows(e.RowIndex).Cells(i).Value
                        Select Case LCase(.Columns(i).Name)
                            Case "units" : units = parseNum(value)
                            Case "price" : price = parseNum(value)
                            Case "discount" : discount = parseNum(value)
                            Case "amount" : colAmount = i
                        End Select
                    Next
                    amount = units * price * (1 …
ddanbe commented: Nice! +15
xrjf 230 Posting Whiz

How do you populate your datagrid?

xrjf 230 Posting Whiz

Set the code in this other way and see if it still throws an exception:

        For Each ctrl As Control In Me.Controls("pnlMainPanel").Controls
            If ctrl.GetType Is GetType(Windows.Forms.Panel) Then
                Select Case ctrl.GetType
                    Case GetType(TextBox)
                        ' do whatever '
                    Case GetType(ComboBox)
                    Case GetType(RadioButton)
                        Dim r As RadioButton = CType(ctrl, RadioButton)
                        If r.Name = "rbttnM" AndAlso r.Checked Then
                            ' do whatever '
                        ElseIf r.Name = "rbttnF" AndAlso r.Checked Then
                            ' do whatever '
                        End If
                End Select
            End If
        Next
xrjf 230 Posting Whiz

That's all ?

rproffitt commented: That's all folks! +0
xrjf 230 Posting Whiz

Do you mean how to input scanned bar codes? If yes, see for example: here

rproffitt commented: 3 men walk into a bar, the 4th man ducks. +12
xrjf 230 Posting Whiz

I'm not very sure of what you're trying, but perhaps:

SELECT Format([expr1],"# %") AS expr2, count(totvisit)/count(totrem) AS expr1 
FROM (   
            SELECT DISTINCT remid 
            FROM            remtable
            WHERE           remtable.pacid = 94) AS totrem,
     ( 
            SELECT DISTINCT visitaid
            FROM            jurnal  AS b
            WHERE           jurnal.pacient_id = 94) AS totvisit
xrjf 230 Posting Whiz
dim dgv as datagridview = DirectCast(sender,DatagridView)
if dgv.name = "..." then
xrjf 230 Posting Whiz

Just to rotate in both directions:

Private Sub rotatingRectangle_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
    Try
        Dim alpha As Double
        Static oldSign As Int32 = -1
        Static oldSign2 As Int32 = -1
        Dim sign As Int32 = oldSign2
        oldSign2 = oldSign
        If bDrag Then
            If oldpos.X = 0 AndAlso oldpos.Y = 0 Then
                oldpos = New Point(mp.X, mp.Y)
                Exit Sub
            End If
            alpha = Math.Atan2((-mp.Y - center.Y), _
                                (mp.X - center.X))
            alpha = Math.Abs(alpha)
            If mp.X > center.X AndAlso mp.Y - oldpos.Y > 0 Then
                sign = 1
            ElseIf mp.X < center.X AndAlso mp.Y - oldpos.Y < 0 Then
                sign = 1
            ElseIf mp.X > center.X AndAlso mp.Y - oldpos.Y < 0 Then
                sign = -1
            ElseIf mp.X < center.X AndAlso mp.Y - oldpos.Y < 0 Then
                sign = -1
            ElseIf mp.Y - oldpos.Y Then
                sign = -1
            End If
            alpha = oldAlpha + alpha * sign
            oldpos = New Point(mp.X, mp.Y)
            oldSign = sign
        Else
            alpha = oldAlpha
        End If
        e.Graphics.TranslateTransform(center.X, center.Y)
        e.Graphics.RotateTransform(alpha)
        e.Graphics.DrawImage(bmpBlue, New Point(-w / 2, -h / 2))
        oldAlpha = alpha
    Catch ex As Exception

    End Try
End Sub
xrjf 230 Posting Whiz

A briefer and improved version to rotate the image:

    Private Sub rotatingRectangle_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        Try
            Dim alpha As Double
            If bDrag Then
                If oldpos.X = 0 AndAlso oldpos.Y = 0 Then
                    oldpos = New Point(mp.X, mp.Y)
                    Exit Sub
                End If
                alpha = Math.Atan2(-mp.Y - center.Y, mp.X - center.X)
                alpha += oldAlpha
                oldpos = New Point(mp.X, mp.Y)
            Else
                alpha = oldAlpha
            End If
            e.Graphics.TranslateTransform(center.X, center.Y)
            e.Graphics.RotateTransform(alpha)
            e.Graphics.DrawImage(bmpBlue, New Point(-w / 2, -h / 2))
            oldAlpha = alpha
        Catch ex As Exception

        End Try
    End Sub
xrjf 230 Posting Whiz

I think string should be converted in numeric, say
Format(CStr(Mid(dr, 2, 6)) + 1, "E00000#") or Format(CInt(Mid(dr, 2, 6)) + 1, "E00000#")

xrjf 230 Posting Whiz

I don't know exactly what is your code, but perhaps you could call createTable() passing the selected index as argument:

Sub createTable(selectedIndex As Int32)
    Dim n As Int32 = 200
    Static vinte(-1) As Int32
    Try
        If vinte.Length = 0 Then
            ' initialize vinte() just in the first call: '
             ReDim vinte(n - 1)
           Dim rnd As New Random
            For i = 0 To n - 1
                vinte(i) = i + 1
            Next
            Dim vByte(n - 1) As Byte
            rnd.NextBytes(vByte)
            Array.Sort(vByte, vinte)
        End If

        Dim con As New SqlClient.SqlConnection("data source=ADMIN-PC\SQLEXPRESS;initial catalog=Warehouse;Integrated Security=True")
        Dim cmd As New SqlCommand()
        cmd.Connection = con
        con.Open()
        cmd.CommandText = "CREATE TABLE  'table" & selectedIndex & vinte(selectedIndex) & "'(ID int ,LastName varchar(255) NOT NULL,FirstName varchar(255),Age int, PRIMARY KEY (ID))"
        cmd.CommandType = CommandType.Text
        cmd.ExecuteNonQuery()
    Catch ex As Exception
        Throw ex
    End Try
End Sub
xrjf 230 Posting Whiz

Here the image rotates while dragging around the center clockwise or not, although when the mouse moves horizontally the spinning slows. A workaround could be to spin just in one direction and take into account that when dragging and y=0 the image continues spinning.

rotatingRectangle.PNG

Imports System.Drawing
Imports System.Reflection
Imports System.IO

Public Class rotatingRectangle

    Dim bDrag As Boolean
    Dim oldpos As New Point(0, 0)
    Dim oldAlpha As Double = 0.0
    WithEvents bmpBlue As Bitmap
    Dim center As Point
    Dim w, h, cliW, cliH As Single
    Dim mp As Point
    Private Sub rotatingRectangle_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        Try
            Dim filename As String = "viento de cizalladura.png"
            Dim _assembly As [Assembly] = [Assembly].GetExecutingAssembly
            Dim _stream As Stream = _assembly.GetManifestResourceStream("MyNameSpace." + filename)

            bmpBlue = Bitmap.FromStream(_stream)
            _stream.Close()
            w = bmpBlue.Width
            h = bmpBlue.Height
            cliW = Me.ClientRectangle.Width
            cliH = Me.ClientRectangle.Height
            center = New Point(cliW / 2, _
                              cliH / 2)
            Me.DoubleBuffered = True
        Catch ex As Exception

        End Try
    End Sub
    Private Sub bmpBlue_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
        bDrag = True
    End Sub

    Private Sub bmpBlue_MouseUp(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
        bDrag = False
    End Sub
    Private Sub bmpBlue_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
        mp = New Point(e.X, e.Y)
        Me.Refresh()
    End Sub

    Private Sub rotatingRectangle_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        Try
            Dim alpha As Double
            If bDrag Then
                If oldpos.X = 0 AndAlso oldpos.Y = 0 Then
                    oldpos = New Point(mp.X - center.X, mp.Y - center.Y)
                    Exit Sub …
xrjf 230 Posting Whiz

Sorry, rnd should be an instance of Random class:

dim rnd as new Random()
xrjf 230 Posting Whiz

I guess the table names are being repeated, to avoid this problem you may set the 200 numbers, firstly ordered in vinteand then reorder randomly:

        Dim n As Int32 = 200
        Dim vinte(n - 1) As Int32
        For i As Int32 = 0 To n - 1
            vinte(i) = i + 1
        Next
        Dim vByte(n - 1) As Byte
        rnd.NextBytes(vByte)
        ' vByte() contains random entries and vinte() is ordered.'
        ' sort vByte (keys) and reorder vinte entries in the same'
        ' way. Suppose vByte=25,4,7 and vinte=1,2,3 after Array.Sort'
        Array.Sort(vByte, vinte)
        ' vByte=4,7,25 and vinte=2,3,1'
xrjf 230 Posting Whiz

There is missing a catch instruction after line #15:

catch  
    {  
    } 
xrjf 230 Posting Whiz

Why do you create a new instance of DataGridView in DataGridView dataGridView10 = new DataGridView(); ?? You should employ the same DataGridView present in the form.

xrjf 230 Posting Whiz

I would set datagrid's property AllowUserToAddRow to False and then manage to add a row by code. For example:

    Private Sub btnNext_Click(sender As System.Object, e As System.EventArgs) Handles btnNext.Click
        Try
            Dim caseNum As Int32 = 0
            If Int32.TryParse(tbCase.Text, caseNum) Then
                With DataGridView1
                    Dim index As Int32 = .Rows.Count
                    .Rows.Add()
                    .Rows(index).Cells(0).Value = caseNum
                End With
            End If
        Catch ex As Exception
            Throw ex
        End Try
    End Sub
xrjf 230 Posting Whiz

I've search a quite and what you're looking for seems quite sure to not work. Another work around is to add a 'myWindow' class inherited from window and set the Initialized event as I did before. In this way you won't have to add the Style attribute, but you'll need to derive the MainWindow, as any other window, from 'myWindow'.

xrjf 230 Posting Whiz

Additionally supressing Style="{StaticResource MyWindowStyle}" you may add this event in code behind MainWindow:

    Private Sub MainWindow_Initialized(sender As System.Object, e As System.EventArgs)
        Me.Style = FindResource("MyWindowStyle")
    End Sub
xrjf 230 Posting Whiz

WpfStyleFile.PNG
I've tried your code and the only way I could change the window's background was setting x:Key.

MainWindow.xaml:

<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Title="MainWindow" Style="{StaticResource MyWindowStyle}"  >
    <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <TextBlock Grid.Row="0" Text="Hello" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
        <TextBox Grid.Row="1" Height="25" Width="100" HorizontalAlignment="Center" VerticalAlignment="Center" />
    </Grid>
</Window>

myStyle.xaml:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Style x:Key="MyWindowStyle">
        <Setter Property="Control.Height" Value="500" />
        <Setter Property="Control.Width" Value="500" />
        <Setter Property="Control.Background" >
            <Setter.Value>
                <SolidColorBrush Color="Red" Opacity="0.2" />
            </Setter.Value>
        </Setter>
        <Setter Property="Window.Title" Value="Styled Window"/>
        <Setter Property="Control.HorizontalAlignment" Value="Center" />
        <Setter Property="Control.VerticalAlignment" Value="Center" />
        <Setter Property="Window.WindowStyle" Value="None"/>
        <Setter Property="Window.AllowsTransparency" Value="True"/>
    </Style>
    <Style TargetType="{x:Type Grid}">
        <Setter Property="Height" Value="250" />
        <Setter Property="Width" Value="250" />
        <Setter Property="Background" Value="LightSalmon" />
        <Setter Property="HorizontalAlignment" Value="Center" />
        <Setter Property="VerticalAlignment" Value="Center" />
    </Style>
</ResourceDictionary>

Application.xaml:

<Application x:Class="Application"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    StartupUri="MainWindow.xaml" >
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="myStyle.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
</Application.Resources>
</Application>
xrjf 230 Posting Whiz

You are welcome

xrjf 230 Posting Whiz

You may do a trick: set a numberic value to Path attribute for Programme, Felt, and so on:

<?xml version="1.0" encoding="utf-8"?>
<Programme Path="1">
  <Feld Icon="Folder.ico" Path="2">
    Feld 1<VisualStudio Path="C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe" Icon="VS.png">Visual Studio</VisualStudio>
    <Excel Path="C:\Program Files\Microsoft Office 15\root\office15\EXCEL.EXE" Icon="Excel.png">Excel</Excel>
  </Feld>
  <Home Icon="Folder.ico" Path="3">
    Home Place<Notepad Path="C:\Program Files\Notepad++\notepad++.exe" Icon="notepad.png">Notepad ++</Notepad>
  </Home>
</Programme>

Then change mouse double click to examine if Path is numeric.

Private Sub me_NodeMouseDoubleClick(sender As Object, e As System.Windows.Forms.TreeNodeMouseClickEventArgs) Handles TreeView1.NodeMouseDoubleClick
    Try
        Dim Path As String = TreeView1.SelectedNode.Name
        If IsNumeric(Path) Then
            Dim nAction As Int32 = Int32.Parse(Path)
            Select Case nAction
                Case 1
                    ' do job for Path="1" ' 
                Case 2
                    ' do job for Path="2" '
                Case 3
                    ' do job for Path="3" '
            End Select
        Else
            If File.Exists(Path) Then
                Process.Start(Path)
            End If
        End If
    Catch ex As Exception
        MsgBox("kein Programm gefunden")
    End Try
End Sub

Whenever you add a new folder to the XML you may set 'Path' attribute to the number of job it must do.

xrjf 230 Posting Whiz

Of course your class seems to be called XmlTreeView so replace line #7 Public Class treeViewLoadXml by Public Class XmlTreeView. I case of doubt please tell me.

xrjf 230 Posting Whiz

Ok, forget the last I said and here is the code again, supposed the TreeView control is named TreeView1:

Imports System.Xml
Imports System.IO
Imports System.Text
Imports System.Text.RegularExpressions

Public Class treeViewLoadXml
    Dim imgLst As New ImageList
    Dim vImgPath(-1) As String, iv As Int32 = 0
    Private Sub treeViewLoadXml_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Load_XML()
    End Sub
    Public Sub Load_XML()
        Try
            ' Get Xml's file stream.

            imgLst.ImageSize = New Drawing.Size(30, 27)

            Dim vPath() As String = Split(Application.ExecutablePath, "\")
            vPath(vPath.Length - 1) = "XMLFile2.xml"
            Dim filepath As String = Join(vPath, "\")
            Dim _rstream As New FileStream(filepath, FileMode.Open)

            ' Load Xml document.
            '
            Dim dom As New XmlDocument()
            dom.Load(_rstream)
            _rstream.Close()

            ' Initialize treeView control.
            '
            TreeView1.BeginUpdate()
            TreeView1.Nodes.Clear()
            TreeView1.Nodes.Add(New TreeNode(dom.DocumentElement.Name))

            ' Populate the treeView with the dom nodes.
            '
            AddNode(dom.DocumentElement, TreeView1.Nodes(0))
            If iv Then
                For i = 0 To iv - 1
                    imgLst.Images.Add(Image.FromFile(vImgPath(i)))
                Next
                TreeView1.ImageList = imgLst
            End If
            TreeView1.EndUpdate()
            TreeView1.ExpandAll()
        Catch xmlEx As XmlException
            MessageBox.Show(xmlEx.Message)
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub
    Private Sub AddNode(ByVal inXmlNode As XmlNode, ByVal inTreeNode As TreeNode)
        Dim i As Integer
        If inXmlNode.HasChildNodes Then
            Dim nodeList As XmlNodeList
            nodeList = inXmlNode.ChildNodes
            i = 0
            While i <= nodeList.Count - 1
                Dim xNode As XmlNode = inXmlNode.ChildNodes(i)
                Dim imgIndex As Int32 = -1
                If xNode.Attributes IsNot Nothing Then
                    For Each att As XmlAttribute In xNode.Attributes
                        If att.Name = "Icon" Then
                            imgIndex = addImage(att.Value)
                            Exit For
                        End If
                    Next
                End If
                Dim tNode As New TreeNode(xNode.Name)
                Dim bIsTxt As Boolean = False
                If tNode.Text = "#text" Then …
xrjf 230 Posting Whiz

The class starting at lines #13 and #14 define a user control (which inherits from TreeView):

Public Class MyTreeNode
    Inherits TreeView
    ...

You should add this user control to your form, i.e., build the project and add the control from the ToolBox. You can find an explanation Here

xrjf 230 Posting Whiz

That's because your control's name is perhaps treeview1 -a treeview control- and if it's not an instance of MyTreeNode. To replace treeView1 by an instance of MyTreeNode look in the tools bar (in mine's near the top of the tools' bar).

xrjf 230 Posting Whiz

Note that lines #92 to #95 reserve the path in 'Name' property, which is latter used in line #113 to execute the file in Process.Start

xrjf 230 Posting Whiz

Here the control is inheriting from TreeView instead of TreeNode:

Imports System.Xml
Imports System.Reflection
Imports System.IO
Imports System.Text
Imports System.Text.RegularExpressions

Public Class treeViewLoadXml
    Private Sub treeViewLoadXml_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        MyTreeNode1.Load_XML()
    End Sub
End Class

Public Class MyTreeNode
    Inherits TreeView
    Dim imgLst As New ImageList
    Dim vImgPath(-1) As String, iv As Int32 = 0
    Public Sub Load_XML()
        Try
            ' Get Xml's file stream.

            imgLst.ImageSize = New Drawing.Size(30, 27)

            Dim vPath() As String = Split(Application.ExecutablePath, "\")
            vPath(vPath.Length - 1) = "XMLFile2.xml"
            Dim filepath As String = Join(vPath, "\")
            Dim _rstream As New FileStream(filepath, FileMode.Open)

            ' Load Xml document.
            '
            Dim dom As New XmlDocument()
            dom.Load(_rstream)
            _rstream.Close()

            ' Initialize treeView control.
            '
            BeginUpdate()
            Nodes.Clear()
            Nodes.Add(New TreeNode(dom.DocumentElement.Name))

            ' Populate the treeView with the dom nodes.
            '
            AddNode(dom.DocumentElement, Nodes(0))
            If iv Then
                For i = 0 To iv - 1
                    imgLst.Images.Add(Image.FromFile(vImgPath(i)))
                Next
                ImageList = imgLst
            End If
            EndUpdate()
            ExpandAll()
        Catch xmlEx As XmlException
            MessageBox.Show(xmlEx.Message)
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub
    Private Sub AddNode(ByVal inXmlNode As XmlNode, ByVal inTreeNode As TreeNode)
        Dim i As Integer
        If inXmlNode.HasChildNodes Then
            Dim nodeList As XmlNodeList
            nodeList = inXmlNode.ChildNodes
            i = 0
            While i <= nodeList.Count - 1
                Dim xNode As XmlNode = inXmlNode.ChildNodes(i)
                Dim imgIndex As Int32 = -1
                If xNode.Attributes IsNot Nothing Then
                    For Each att As XmlAttribute In xNode.Attributes
                        If att.Name = "Icon" Then
                            imgIndex = addImage(att.Value)
                            Exit For
                        End If
                    Next
                End If
                Dim tNode As New TreeNode(xNode.Name)
                Dim bIsTxt As Boolean = False
                If tNode.Text = "#text" Then …
xrjf 230 Posting Whiz

treeView4.PNG
Let's see how it goes this time. I've left commented the old instruction to visualize better the change.

    Private Sub AddNode(ByVal inXmlNode As XmlNode, ByVal inTreeNode As TreeNode)
        Dim i As Integer
        If inXmlNode.HasChildNodes Then
            Dim nodeList As XmlNodeList
            nodeList = inXmlNode.ChildNodes
            i = 0
            While i <= nodeList.Count - 1
                Dim xNode As XmlNode = inXmlNode.ChildNodes(i)
                Dim imgIndex As Int32 = -1
                If xNode.Attributes IsNot Nothing Then
                    For Each att As XmlAttribute In xNode.Attributes
                        If att.Name = "Icon" Then
                            imgIndex = addImage(att.Value)
                            Exit For
                        End If
                    Next
                End If
                Dim tNode As New TreeNode(xNode.Name)
                Dim bIsTxt As Boolean = False
                If tNode.Text = "#text" Then
                    tNode.Text = xNode.Value
                    bIsTxt = True
                End If
                If imgIndex <> -1 Then
                    tNode.ImageIndex = imgIndex
                End If
                If bIsTxt Then
                    'inTreeNode.Text += " " + tNode.Text '
                    inTreeNode.Text = tNode.Text
                Else
                    inTreeNode.Nodes.Add(tNode)
                    AddNode(xNode, tNode)
                End If
                i += 1
            End While
        End If
    End Sub
xrjf 230 Posting Whiz

Sorry, I can't understand what's wrong now. Could you explain more? Your last image looks like what you were after. In any case, by now can't you resolve it by yourself?

xrjf 230 Posting Whiz

@dark.knight Let me suggest to you to start a new threat under Programming/Web Development/Asp.net, as this threat says it's been answered. Thank you.

xrjf 230 Posting Whiz

Possibly you're look for a solution like the one on this threat Click Here

xrjf 230 Posting Whiz

For me the solution has been: 1) set up a home group 2) add a network location: in "This PC" right click and selected that option and followed the wizard. 3) in my case, on the second PC I had to install MS Office Database Engine 2010 From Here
Note: on the wizard the location was "\\myServer\folder" this is, a location in 'This PC'. Of course, the database goes into that folder

xrjf 230 Posting Whiz

It's more practical to change the file extension from .csv to .txt and, then, open with Excel.