K
k7s41gx
Guest
Hey Guys,
I am extremely new to VB WPF. I am use to using the old vb6 style. What I am trying to do is access a datagrid control on window2 from window1. I would like to be able to do this the old way as window2.datagrid1 for example. Is there a way to do this? After a TON of googling and not understanding the datacollection thing I have set the datagrid to x:Fieldname="public" but this does not help.
Any idea and / or sample projects to help with this would be greatly appreciated, thanks!
MAINWINDOW LOADS NEW WINDOWS
Private Sub SUPID()
If TextBox1.Text.Length < 2 Then
MessageBox.Show("You need to enter a valid supervisor ID.")
Else
Dim fileName As String = IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SUP.xlsx")
Dim TextToFind As String = TextBox1.Text ' exists
Dim Value As String = SearchExcelWorkSheet(fileName, "SUP", "U", TextToFind, "B")
If Not String.IsNullOrWhiteSpace(Value) Then
Dim frmload As New Window1
Dim frmload2 As New hidden1
frmload.Show()
frmload.TextBox1.Text = "Welcome " & Value
frmload2.Show()
frmload2.Label1.Content = TextBox1.Text
Me.Hide()
Else
MessageBox.Show("You need to enter a valid supervisor ID.")
End If
End If
End Sub
WINDOW1 LOADING SCREEN
Public Class Window1
Private Sub LOADER()
Dim xlApp As Excel.Application = Nothing
Dim xlWorkBooks As Excel.Workbooks = Nothing
Dim xlWorkBook As Excel.Workbook = Nothing
Dim xlWorkSheet As Excel.Worksheet = Nothing
Dim xlWorkSheets As Excel.Sheets = Nothing
Dim xlApp2 As Excel.Application = Nothing
Dim xlWorkBooks2 As Excel.Workbooks = Nothing
Dim xlWorkBook2 As Excel.Workbook = Nothing
Dim xlWorkSheet2 As Excel.Worksheet = Nothing
Dim xlWorkSheets2 As Excel.Sheets = Nothing
Dim fileName As String = IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "2018RAW.xlsx")
Dim fileName2 As String = IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "2019RAW.xlsx")
Dim counta As Integer
Dim countb As Integer
counta = 0
xlApp = New Excel.Application
xlApp.Visible = False
xlApp.DisplayAlerts = False
xlWorkBooks = xlApp.Workbooks
xlWorkBook = xlWorkBooks.Open(fileName)
xlWorkSheets = xlWorkBook.Sheets
xlWorkSheet = xlWorkBook.Sheets("2018RAW")
counta = xlWorkSheet.UsedRange.Rows.Count()
countb = 0
xlApp2 = New Excel.Application
xlApp2.Visible = False
xlApp2.DisplayAlerts = False
xlWorkBooks2 = xlApp2.Workbooks
xlWorkBook2 = xlWorkBooks2.Open(fileName2)
xlWorkSheets2 = xlWorkBook2.Sheets
xlWorkSheet2 = xlWorkBook2.Sheets("2019RAW")
countb = xlWorkSheet2.UsedRange.Rows.Count()
ProgressBar1.Value = 0
For i As Integer = 1 To 33
'Where I need to add columns to datagrid1 on window hidden1
Next
'For i As Integer = 1 To counta
' String =
' frmbrick.DataGrid1.Items.Add(
'DataGridView1.Rows.Add(New String() {Value1, Value2, Value3})
'newVersionRow.PC_Name = xlWorkSheet.Cells(i, 1).value.ToString()
'ProgressBar1.Value = ProgressBar1.Value + 1
'Next
'For i As Integer = 2 To countb
'Next
xlWorkBook.Close()
xlApp.UserControl = True
xlApp.Quit()
xlWorkBook2.Close()
xlApp2.UserControl = True
xlApp2.Quit()
End Sub
WINDOW HIDDEN1
Public Class hidden1
End Class
Continue reading...
I am extremely new to VB WPF. I am use to using the old vb6 style. What I am trying to do is access a datagrid control on window2 from window1. I would like to be able to do this the old way as window2.datagrid1 for example. Is there a way to do this? After a TON of googling and not understanding the datacollection thing I have set the datagrid to x:Fieldname="public" but this does not help.
Any idea and / or sample projects to help with this would be greatly appreciated, thanks!
MAINWINDOW LOADS NEW WINDOWS
Private Sub SUPID()
If TextBox1.Text.Length < 2 Then
MessageBox.Show("You need to enter a valid supervisor ID.")
Else
Dim fileName As String = IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SUP.xlsx")
Dim TextToFind As String = TextBox1.Text ' exists
Dim Value As String = SearchExcelWorkSheet(fileName, "SUP", "U", TextToFind, "B")
If Not String.IsNullOrWhiteSpace(Value) Then
Dim frmload As New Window1
Dim frmload2 As New hidden1
frmload.Show()
frmload.TextBox1.Text = "Welcome " & Value
frmload2.Show()
frmload2.Label1.Content = TextBox1.Text
Me.Hide()
Else
MessageBox.Show("You need to enter a valid supervisor ID.")
End If
End If
End Sub
WINDOW1 LOADING SCREEN
Public Class Window1
Private Sub LOADER()
Dim xlApp As Excel.Application = Nothing
Dim xlWorkBooks As Excel.Workbooks = Nothing
Dim xlWorkBook As Excel.Workbook = Nothing
Dim xlWorkSheet As Excel.Worksheet = Nothing
Dim xlWorkSheets As Excel.Sheets = Nothing
Dim xlApp2 As Excel.Application = Nothing
Dim xlWorkBooks2 As Excel.Workbooks = Nothing
Dim xlWorkBook2 As Excel.Workbook = Nothing
Dim xlWorkSheet2 As Excel.Worksheet = Nothing
Dim xlWorkSheets2 As Excel.Sheets = Nothing
Dim fileName As String = IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "2018RAW.xlsx")
Dim fileName2 As String = IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "2019RAW.xlsx")
Dim counta As Integer
Dim countb As Integer
counta = 0
xlApp = New Excel.Application
xlApp.Visible = False
xlApp.DisplayAlerts = False
xlWorkBooks = xlApp.Workbooks
xlWorkBook = xlWorkBooks.Open(fileName)
xlWorkSheets = xlWorkBook.Sheets
xlWorkSheet = xlWorkBook.Sheets("2018RAW")
counta = xlWorkSheet.UsedRange.Rows.Count()
countb = 0
xlApp2 = New Excel.Application
xlApp2.Visible = False
xlApp2.DisplayAlerts = False
xlWorkBooks2 = xlApp2.Workbooks
xlWorkBook2 = xlWorkBooks2.Open(fileName2)
xlWorkSheets2 = xlWorkBook2.Sheets
xlWorkSheet2 = xlWorkBook2.Sheets("2019RAW")
countb = xlWorkSheet2.UsedRange.Rows.Count()
ProgressBar1.Value = 0
For i As Integer = 1 To 33
'Where I need to add columns to datagrid1 on window hidden1
Next
'For i As Integer = 1 To counta
' String =
' frmbrick.DataGrid1.Items.Add(
'DataGridView1.Rows.Add(New String() {Value1, Value2, Value3})
'newVersionRow.PC_Name = xlWorkSheet.Cells(i, 1).value.ToString()
'ProgressBar1.Value = ProgressBar1.Value + 1
'Next
'For i As Integer = 2 To countb
'Next
xlWorkBook.Close()
xlApp.UserControl = True
xlApp.Quit()
xlWorkBook2.Close()
xlApp2.UserControl = True
xlApp2.Quit()
End Sub
WINDOW HIDDEN1
Public Class hidden1
End Class
Continue reading...