Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Setting visual properties with DataGrid

Posted on 2004-09-01
2
Medium Priority
?
198 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 200 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

783 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