Solved

Setting visual properties with DataGrid

Posted on 2004-09-01
2
150 Views
Last Modified: 2010-04-23
Hey all,

This is probably a real simple question but I couldn't figure out how to do this :/

Anyway I am trying to format my header row in a DataGrid but can't seem to work out how to set all the properties I want.  I have listed the properties below and would really appreciate if you could please provide some sample code that will format the text accordingly.

The settings I would like are:

Font - Arial
Font size - 16
Font settings - Bold
Column width - Width of Datagrid / 7 (Which is how many columns I have)

Thanks!

Dwayne
0
Comment
Question by:Visual_Pro
2 Comments
 
LVL 25

Accepted Solution

by:
RonaldBiemans earned 50 total points
ID: 11949790
something like this

        DataGrid1.DataSource = ds.Tables(0)

        Dim f As New System.Drawing.Font("Arial", 16.0F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, System.Byte))
        DataGrid1.HeaderFont = f
        Dim grdTableStyle1 As New DataGridTableStyle
        grdTableStyle1.MappingName = ds.Tables(0).TableName
        grdTableStyle1.HeaderFont = f
        DataGrid1.TableStyles.Add(grdTableStyle1)
        For x As Integer = 0 To ds.Tables(0).Columns.Count - 1
            DataGrid1.TableStyles(0).GridColumnStyles(x).Width = CInt(DataGrid1.Width / (ds.Tables(0).Columns.Count))
        Next

although this

Column width - Width of Datagrid / 7 (Which is how many columns I have)

won't give you the result you where looking for look here for a better solution

http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q1004q


0
 

Author Comment

by:Visual_Pro
ID: 11978901
Hey thanks for that.  You solved my problem easily :)
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video discusses moving either the default database or any database to a new volume.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now