T
tshad
I may be wrong here (and probably am) but from what I have been reading when
when I look at the data from the DataGrid, I am actually seeing what is in
the DataGrid. But I guess I am wrong here.
I have a Table that has a list of emails in it and a DataGrid that displays
some of the columns. I allow the user to select the email they want by
selecting the row. I then take the data out of DataTable and not the
DataGrid at the CurrentRowIndex.
This works fine unless I allow them to sort the DataGrid. The the rows are
not in the same order so the CurrentRowIndex in the DataGrid is not the same
as the row in the DataTable.
Here is the code I am using:
*******************************************************************************
Private Sub EmailDataGrid_MouseUp(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) Handles
EmailDataGrid.MouseUp
Dim strInput As String
Dim numRows As Integer =
EmailDataGrid.BindingContext(EmailDataGrid.DataSource, _
EmailDataGrid.DataMember).Count
strInput =
ds.Tables("Emails").Rows(EmailDataGrid.CurrentRowIndex)("id")
Call GetSelectedEmail(EmailDataGrid.CurrentRowIndex)
End Sub
Private Sub GetSelectedEmail(ByVal row As Integer)
EmailFrom.Text = ds.Tables("Emails").Rows(row)("from_address")
EmailTo.Text = ds.Tables("Emails").Rows(row)("to_addresses")
CC.Text = ds.Tables("Emails").Rows(row)("cc_addresses")
BCC.Text = ds.Tables("Emails").Rows(row)("bcc_addresses")
Subject.Text = ds.Tables("Emails").Rows(row)("subject")
Body.Text = ds.Tables("Emails").Rows(row)("body")
TabPage1.SendToBack()
End Sub
*******************************************************************************
How can I change this to look at the correct row?
Or how can I get the Data from the DataGrid itself. This might be a problem
as I would need to put all the data in the DataGrid and I can't seem to tell
the DataGrid to hide the data (as I can in asp.net).
I tried doing in the GridColumnStyles, but that didn't seem to work:
With colStyle4
.MappingName = "Status"
.HeaderText = "Status"
.Width = 50
.Alignment = HorizontalAlignment.Left
.TextBox.Visible = False
End With
The Status column still displayed.
Thanks,
Tom
when I look at the data from the DataGrid, I am actually seeing what is in
the DataGrid. But I guess I am wrong here.
I have a Table that has a list of emails in it and a DataGrid that displays
some of the columns. I allow the user to select the email they want by
selecting the row. I then take the data out of DataTable and not the
DataGrid at the CurrentRowIndex.
This works fine unless I allow them to sort the DataGrid. The the rows are
not in the same order so the CurrentRowIndex in the DataGrid is not the same
as the row in the DataTable.
Here is the code I am using:
*******************************************************************************
Private Sub EmailDataGrid_MouseUp(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) Handles
EmailDataGrid.MouseUp
Dim strInput As String
Dim numRows As Integer =
EmailDataGrid.BindingContext(EmailDataGrid.DataSource, _
EmailDataGrid.DataMember).Count
strInput =
ds.Tables("Emails").Rows(EmailDataGrid.CurrentRowIndex)("id")
Call GetSelectedEmail(EmailDataGrid.CurrentRowIndex)
End Sub
Private Sub GetSelectedEmail(ByVal row As Integer)
EmailFrom.Text = ds.Tables("Emails").Rows(row)("from_address")
EmailTo.Text = ds.Tables("Emails").Rows(row)("to_addresses")
CC.Text = ds.Tables("Emails").Rows(row)("cc_addresses")
BCC.Text = ds.Tables("Emails").Rows(row)("bcc_addresses")
Subject.Text = ds.Tables("Emails").Rows(row)("subject")
Body.Text = ds.Tables("Emails").Rows(row)("body")
TabPage1.SendToBack()
End Sub
*******************************************************************************
How can I change this to look at the correct row?
Or how can I get the Data from the DataGrid itself. This might be a problem
as I would need to put all the data in the DataGrid and I can't seem to tell
the DataGrid to hide the data (as I can in asp.net).
I tried doing in the GridColumnStyles, but that didn't seem to work:
With colStyle4
.MappingName = "Status"
.HeaderText = "Status"
.Width = 50
.Alignment = HorizontalAlignment.Left
.TextBox.Visible = False
End With
The Status column still displayed.
Thanks,
Tom