Solved

Setting visual properties with DataGrid

Posted on 2004-09-01
2
177 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…

726 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