Solved

Setting visual properties with DataGrid

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

617 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