Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Computer Certification > MCSD > About Datagrid Columns

Reply
Thread Tools

About Datagrid Columns

 
 
Kawabzi
Guest
Posts: n/a
 
      09-22-2003
I'd like to know how to control the width of each
DataGrid's column alone to be different from other columns.
Note that my DataGrid is binded to a DataTable.
Thanks

 
Reply With Quote
 
 
 
 
Jay Walters
Guest
Posts: n/a
 
      09-24-2003
Check out Grid Styles...


>-----Original Message-----
>I'd like to know how to control the width of each
>DataGrid's column alone to be different from other

columns.
>Note that my DataGrid is binded to a DataTable.
> Thanks
>
>.
>

 
Reply With Quote
 
 
 
 
Rich
Guest
Posts: n/a
 
      10-03-2003
If you're talking about a Windows Control (as opposed to
Web Control), you need to
instantiate "DataGridTableStyle", which contains
a "ColumnStyles" collection. You add members to the
collection for each of the columns that should appear in
your Grid. Once you've done that, you can manipulate
quite a few properties in both DataGridTableStyles and
the collection members for widths, fonts, colors,
borders, etc.

I hope this sample code will give you a basic model. It
uses DataGridTextBoxColumn objects, which is the
easiest. But you can derive your own classes to use as
ColumnStyles, as well.

Private Sub FillDocGrid(ByVal DocID As Integer)
OleDbSelectCommand2.CommandText=SelectDocsCmd &
DocID.ToString & "'"
DocumentsDA.Fill(TechLibDS, "Documents")

DocGrid.DataSource = TechLibDS
DocGrid.DataMember = "Documents"
Dim DocGridTS As New DataGridTableStyle()
DocGridTS.RowHeadersVisible = False
DocGridTS.MappingName = "TechLibDS.Documents"

' MappingName links DataTable columns to the
' ColumnStyles
Dim IDCS As New DataGridTextBoxColumn()
IDCS.MappingName = "ID"
IDCS.HeaderText = ""
IDCS.Width = 0
DocGridTS.GridColumnStyles.Add(IDCS)

Dim DocDateCS As New DataGridTextBoxColumn()
DocDateCS.MappingName = "DocDate"
DocDateCS.HeaderText = "Date"
DocDateCS.Width = 120
DocGridTS.GridColumnStyles.Add(DocDateCS)

Dim TitleCS As New DataGridTextBoxColumn()
TitleCS.MappingName = "Title"
TitleCS.HeaderText = "Document Title"
TitleCS.Width = 400
DocGridTS.GridColumnStyles.Add(TitleCS)

Dim DescCS As New DataGridTextBoxColumn()
DescCS.MappingName = "Description"
DescCS.HeaderText = "Document Descripition"
DescCS.Width = 800
DocGridTS.GridColumnStyles.Add(DescCS)

DocGrid.TableStyles.Clear()
DocGrid.TableStyles.Add(DocGridTS)
End Sub

HTH - there's more details in MSDN
Rich



>-----Original Message-----
>I'd like to know how to control the width of each
>DataGrid's column alone to be different from other
>-----Original Message-----
>I'd like to know how to control the width of each
>DataGrid's column alone to be different from other

columns.
>Note that my DataGrid is binded to a DataTable.
> Thanks
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
database columns vs. gui columns and sorting ittay.dror@gmail.com Java 5 03-04-2006 10:48 AM
CSS columns problem - faux columns don't work henrybranson@hotmail.com HTML 4 11-24-2005 10:05 AM
convert rows to columns and columns to rows helpful sql ASP .Net 0 05-19-2005 06:03 PM
Binded Datagrid Formatting columns or hiding columns ton ASP .Net Web Controls 2 02-11-2004 04:09 AM
Columns and Inherited Datagrid...Active Schema does not support columns rob thomson ASP .Net Datagrid Control 0 09-04-2003 03:09 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57