RE: listbox and Datagrid, 2 tables, and a relationship
From: Steven Cheng[MSFT] (v-schang_at_online.microsoft.com)
Date: 04/06/04
- Next message: Priyank: "Binding"
- Previous message: Ying-Shen Yu[MSFT]: "RE: combo box selectedItem"
- In reply to: M K: "RE: listbox and Datagrid, 2 tables, and a relationship"
- Next in thread: Steven Cheng[MSFT]: "RE: listbox and Datagrid, 2 tables, and a relationship"
- Reply: Steven Cheng[MSFT]: "RE: listbox and Datagrid, 2 tables, and a relationship"
- Reply: M K: "RE: listbox and Datagrid, 2 tables, and a relationship"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 06 Apr 2004 06:35:19 GMT
Hi Mark,
I'm sorry that I haven't noticed that you're using VB.NET. As for the new
questions:
"How do I keep a column from being shown in my datagrid. It currently shows
the ProgramID, which I would like to keep behind the scenes."
You can make use of the DataGridTableStyle to format the outlooking of the
winform datagrid, you can control how many columns to display and how they
display in the certain datagrid. For detailed description, you can refer to
the following reference and samples in MSDN:
#Formatting the Windows Forms DataGrid Control in Visual Basic
http://msdn.microsoft.com/library/en-us/dv_vstechart/html/vbtchFormattingWin
dowsFormsDataGridVisualBasicPrimer.asp?frame=true
#DataGridColumnStyle Class
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwindowsformsda
tagridcolumnstyleclasstopic.asp?frame=true
As for your situation that you have three columns("ProgramID", "Data1",
"Data2" ...) and only want to display the latter twos in datagrid, you can
create a tablestyle which only contains two tablecolumns and apply it onto
the datagrid, such as below:
Protected Sub AddFormattedStyle()
Dim tsDetail As New DataGridTableStyle()
tsDetail.MappingName = "tbDetail"
Dim tbcData1 As New DataGridTextBoxColumn()
tbcData1.MappingName = "Data1"
tbcData1.HeaderText = "Program Data1"
Dim tbcData2 As New DataGridTextBoxColumn()
tbcData2.MappingName = "Data2"
tbcData2.HeaderText = "Program Data2"
tsDetail.GridColumnStyles.Add(tbcData1)
tsDetail.GridColumnStyles.Add(tbcData2)
dgDetail.TableStyles.Add(tsDetail)
End Sub 'AddFormattedStyle
#The above function is apply a DataGridTableStyle onto the dgDetail
DataGrid which only show two columns(without the "ProgramID" column).
In addition, here is a webpage which can help to translate C# code into
VB.NET. I believe it will be helpful to you when you viewing C# code
sample. Thanks.
#C# to VB.NET Translator
http://authors.aspalliance.com/aldotnet/examples/translate.aspx
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
- Next message: Priyank: "Binding"
- Previous message: Ying-Shen Yu[MSFT]: "RE: combo box selectedItem"
- In reply to: M K: "RE: listbox and Datagrid, 2 tables, and a relationship"
- Next in thread: Steven Cheng[MSFT]: "RE: listbox and Datagrid, 2 tables, and a relationship"
- Reply: Steven Cheng[MSFT]: "RE: listbox and Datagrid, 2 tables, and a relationship"
- Reply: M K: "RE: listbox and Datagrid, 2 tables, and a relationship"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|