Solved

Setting visual properties with DataGrid

Posted on 2004-09-01
2
186 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

728 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