T
tshad
I have a dataGrid that I filled with files from my directory. I am using VS
2003 and Windows Forms.
************************************************************
Dim dirInfo As DirectoryInfo = New
DirectoryInfo("C:/ImportFile/Coreland")
' FileListTable.Columns.Add("FullName", GetType(String))
FileListTable.Columns.Add("FileName", GetType(String))
FileListTable.Columns.Add("Length", GetType(Integer))
FileListTable.Columns.Add("DateModified", GetType(DateTime))
For Each file As FileInfo In dirInfo.GetFiles("*")
Dim row As DataRow = FileListTable.NewRow()
' row.Item("FullName") = file.FullName
row.Item("FileName") = file.Name
row.Item("Length") = file.Length
row.Item("DateModified") = file.LastAccessTime
FileListTable.Rows.Add(row)
Next
DataGrid1.DataSource = FileListTable
*******************************************
I want to allow the user to select the row and display file in a text box.
I can do this in asp.net but I can't seem to figure out how to do this as an
event so that when the row is selected it automatically goes and gets the
file and displays it.
Maybe by adding a radio button or something. But I am not sure how add that
to the DataGrid and then have it trigger an event.
At the moment I have my tableStyle set as:
***********************************************
Dim gtStyle As New DataGridTableStyle
gtStyle.MappingName = "FileListTable"
gtStyle.AlternatingBackColor = Color.LightBlue
'
' Create GridColumnStyle objects for the grid columns
'
Dim colStyle1 As New DataGridTextBoxColumn
Dim colStyle2 As New DataGridTextBoxColumn
Dim colStyle3 As New DataGridTextBoxColumn
'
' Set column 1's caption, width and disable editing.
'
With colStyle1
.MappingName = "FileName"
.HeaderText = "File name"
.Width = 300
.Alignment = HorizontalAlignment.Left
.TextBox.Enabled = False
End With
'
' Set column 2's caption, width and disable editing.
'
With colStyle2
.MappingName = "Length"
.HeaderText = "Length"
.Width = 100
.Alignment = HorizontalAlignment.Left
.TextBox.Enabled = True
End With
'
' Set column 3's caption, width and disable editing.
'
With colStyle3
.MappingName = "DateModified"
.HeaderText = "Date Modified"
.Width = 100
.Alignment = HorizontalAlignment.Left
.TextBox.Enabled = True
.Format = "yyyy-MM-dd"
End With
' Add the GridColumnStyles to the DataGrid's Column Styles collection.
'
With gtStyle.GridColumnStyles
.Add(colStyle1)
.Add(colStyle2)
.Add(colStyle3)
End With
'
' Add the GridTableStyle to the DataGrid
'
DataGrid1.TableStyles.Add(gtStyle)
***********************************************
Thanks,
Tom
2003 and Windows Forms.
************************************************************
Dim dirInfo As DirectoryInfo = New
DirectoryInfo("C:/ImportFile/Coreland")
' FileListTable.Columns.Add("FullName", GetType(String))
FileListTable.Columns.Add("FileName", GetType(String))
FileListTable.Columns.Add("Length", GetType(Integer))
FileListTable.Columns.Add("DateModified", GetType(DateTime))
For Each file As FileInfo In dirInfo.GetFiles("*")
Dim row As DataRow = FileListTable.NewRow()
' row.Item("FullName") = file.FullName
row.Item("FileName") = file.Name
row.Item("Length") = file.Length
row.Item("DateModified") = file.LastAccessTime
FileListTable.Rows.Add(row)
Next
DataGrid1.DataSource = FileListTable
*******************************************
I want to allow the user to select the row and display file in a text box.
I can do this in asp.net but I can't seem to figure out how to do this as an
event so that when the row is selected it automatically goes and gets the
file and displays it.
Maybe by adding a radio button or something. But I am not sure how add that
to the DataGrid and then have it trigger an event.
At the moment I have my tableStyle set as:
***********************************************
Dim gtStyle As New DataGridTableStyle
gtStyle.MappingName = "FileListTable"
gtStyle.AlternatingBackColor = Color.LightBlue
'
' Create GridColumnStyle objects for the grid columns
'
Dim colStyle1 As New DataGridTextBoxColumn
Dim colStyle2 As New DataGridTextBoxColumn
Dim colStyle3 As New DataGridTextBoxColumn
'
' Set column 1's caption, width and disable editing.
'
With colStyle1
.MappingName = "FileName"
.HeaderText = "File name"
.Width = 300
.Alignment = HorizontalAlignment.Left
.TextBox.Enabled = False
End With
'
' Set column 2's caption, width and disable editing.
'
With colStyle2
.MappingName = "Length"
.HeaderText = "Length"
.Width = 100
.Alignment = HorizontalAlignment.Left
.TextBox.Enabled = True
End With
'
' Set column 3's caption, width and disable editing.
'
With colStyle3
.MappingName = "DateModified"
.HeaderText = "Date Modified"
.Width = 100
.Alignment = HorizontalAlignment.Left
.TextBox.Enabled = True
.Format = "yyyy-MM-dd"
End With
' Add the GridColumnStyles to the DataGrid's Column Styles collection.
'
With gtStyle.GridColumnStyles
.Add(colStyle1)
.Add(colStyle2)
.Add(colStyle3)
End With
'
' Add the GridTableStyle to the DataGrid
'
DataGrid1.TableStyles.Add(gtStyle)
***********************************************
Thanks,
Tom