Quantcast
Channel: VBForums - WPF, WCF, WF
Viewing all articles
Browse latest Browse all 256

WPF Listbox, Adding Checkbox

$
0
0
Hi All

I would like to add a checkbox into a list box. i know how to do this if i know all the items i need and do it through the xaml. Except I'm looking into a user defined excel spreadsheet adding serial numbers and a checkbox I will later deal with.

I'm not sure if i can. This is what i have so far.
Code:

    Private Sub Load_Btn_Click(sender As Object, e As RoutedEventArgs) Handles Load_Btn.Click
        Dim dlg As New Microsoft.Win32.OpenFileDialog()
        Dim Xcel As New Microsoft.Office.Interop.Excel.Application
        Xcel.Application.DisplayAlerts = False

        dlg.DefaultExt = ".txt"
        dlg.Filter = "Excel Files|*.xls;*.xlsx;*.xlsm"

        Dim result As Nullable(Of Boolean) = dlg.ShowDialog()
        If result = True Then
            ' Open document
            Dim filename As String = dlg.FileName
            Import_FileName = filename
        End If

        Try
            Xcel.Application.Workbooks.Open(Import_FileName)
            Dim worksheet As Object = Xcel.Worksheets("MasterComp")
            worksheet.Activate()

            SiteName = (worksheet.Range("SiteName").Value)
            SiteID.Text = SiteName
        Catch ex As Exception
            MessageBox.Show("IMPORT FAILED", "Load Site fail", MessageBoxButton.OK, MessageBoxImage.Error)
            Xcel.Quit()
        End Try
        STOP_now = False

        Xcel.ActiveSheet.Range("START").Activate()

        Try
            Do Until STOP_now = True
                If Xcel.ActiveCell.Text = "STOP" Then
                    STOP_now = True
                    Exit Do
                End If

                ' Xcel.ActiveSheet.Activate()
                SerialBox.Items.Add((Xcel.ActiveCell.Value))
                Xcel.ActiveCell.Offset(1, 0).Activate()
            Loop
        Catch ex As Exception
            MessageBox.Show("IMPORT FAILED", "Load Site fail", MessageBoxButton.OK, MessageBoxImage.Error)
            MessageBox.Show(ex.Message)
            Xcel.Quit()
        End Try

    End Sub

If this could be done how could you attach a name to it as you go?

Any help would be good
Thanks for reading

Viewing all articles
Browse latest Browse all 256

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>