Vertical Text In Datagridview Column Header

free web hosting
Free Web Hosting > Computers & Tech > Programming > Programming General > BASIC / Visual Basic (.NET)

Vertical Text In Datagridview Column Header

tomtrak
Hi,

I don't know how to rotate a text in a DataGridView column header to be written vertically from bottom to top.
I found a property called GdiVerticalFont in a datagridview ColumnHeadersDefaultCellStyle, but it doesn't work.
I don't have any experience in programming user controls so I hope that someone help me to find a good solution. I would be grateful for any tip how to modify an existing control, where to put the code and what to modify.

Thanks in advance

Reply

tansqrx
I fooled around with trying to get this to work for about 3 hours today with little success. This is what I have found out so far. It looks like using ListView is going to be a dead end. It doesn’t appear to offer any methods for adding custom column types. I have also seen that Microsoft has replaced the DataGrid with DataGridView. Looks like there are some good improvements but many of the examples that I was going to give you have methods not included in DataGridView.

From what I can tell right now this is what you will have to do.

1. Get your DataGridView setup with you data bindings, etc.
2. Create a new class that inherits DataGridViewTextBoxCell
3. Within DataGridViewTextBoxCell, setup all of the text rotations as described in my rotating text tutorial.
4. Add the new column type to the DataGridView.

I will work some more on this later. It appears that this may turn out to be quite a project. In the meantime you might want to refer to some of the following links.

http://msdn2.microsoft.com/en-us/library/7fb61s43.aspx
http://msdn2.microsoft.com/en-us/library/ms299610.aspx

 

 

 


Reply

christy
QUOTE(tomtrak @ Jul 31 2006, 01:39 PM) *
Hi,

I don't know how to rotate a text in a DataGridView column header to be written vertically from bottom to top.
I found a property called GdiVerticalFont in a datagridview ColumnHeadersDefaultCellStyle, but it doesn't work.
I don't have any experience in programming user controls so I hope that someone help me to find a good solution. I would be grateful for any tip how to modify an existing control, where to put the code and what to modify.

Thanks in advance



Hi,

try the following code,

Private Sub dgv_rmxOrdDetail_CellPainting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellPaintingEventArgs) Handles dgv_rmxOrdDetail.CellPainting

If e.RowIndex = -1 Then

e.PaintBackground(e.CellBounds, True)
e.Graphics.TranslateTransform(e.CellBounds.Left, e.CellBounds.Bottom)
e.Graphics.RotateTransform(270)
e.Graphics.DrawString(e.FormattedValue.ToString, e.CellStyle.Font, Brushes.Blue, 5, 5)
e.Graphics.ResetTransform()
e.Handled = True
End If

End Sub

To run this effectively, RowHeader.Visible should be false.

This code is working very properly for me.

bye

Reply

mazel
Hi!

I tried the code that Christy provided. The code didn't go as I've hoped it would, eventhough I've set the RowHeader.Visible to false. And I can't understand how I could change the location of the text. The location of the text was messed up in my program.

But I found another way of implementing this. smile.gif Using the code above :

CODE
Private Sub dgv_rmxOrdDetail_CellPainting(ByVal sender As Object, ByVal e As
         System.Windows.Forms.DataGridViewCellPaintingEventArgs) Handles dgv_rmxOrdDetail.CellPainting

    If e.RowIndex = -1 Then
          Dim sf As New StringFormat(Drawing.StringFormatFlags.DirectionVertical)
          sf.Alignment = StringAlignment.Center

          e.PaintBackground(e.CellBounds, True)
          // e.Graphics.TranslateTransform(e.CellBounds.Left, e.CellBounds.Bottom)
          // e.Graphics.RotateTransform(270)
          e.Graphics.DrawString(e.FormattedValue.ToString, e.CellStyle.Font, Brushes.Blue, e.CellBounds, sf)
          // e.Graphics.ResetTransform()
          e.Handled = True
    End If
End Sub


I can't remember where I've found this. I think the only problem here is that the text is facing the other side (which is the left side). I still can't figure out how I would rotate it. mellow.gif

Reply

tansqrx
I will say that you should have much more luck with DataGridView over DataGrid. I started using DataGridView about a year ago and I have to say that Microsoft added some MUCH need functionality.

Reply

FeedBacker
Deferent Language Books Name Display in Datagrid. How to Change Font?
Vertical Text In Datagridview Column Header

Hi I am Lenu Thomas from INDIA,

There is Deferent Language in India; I am making Library Books Software, I am using �Vb.Net Visual Basic Datagrid� Deferent Language books Name Display in Datagrid. How to Change Font?

I show this Model

No. Book Name Language Price Year Authors Publish
1. The Patmos English 150 2000 Colin Warner OM Publsh
2. ThZ]pkvXI Dt Malayalam 70 1900 Charles John OM Publsh
3. and�ġv F�p t Hindi 300 2005 Abd-Ul - %.. ISPCK

Number 2 Display Malayalam Name, Number 3 Display Hindi Name, How to change in Datagrid Cell

I am Using to Deferent Font this is not work. Please Help send Sample code from VB.Net Visual Basic

My E-Mail lenuthomas att hotmail.Com

-question by Lenu Thomas

Reply

iGuest-Manoj
Window based Application About datagridview Control
Vertical Text In Datagridview Column Header

How to resize datagridview column using seperator (between two columns-( | ) Seperator ) by doubleclick


I want column resize on seerator double click

Reply me as soon as possible


-reply by Manoj

Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

Recent Queries:-
  1. text box vertical vb .net - 0.47 hr back. (1)
  2. winforms datagridview vertical header text - 0.83 hr back. (1)
  3. display header text vertically for gridview - 4.03 hr back. (1)
  4. show vertical header column in datagrid - 4.23 hr back. (1)
  5. datagridview cell edit - 8.67 hr back. (1)
  6. how to add richtextbox into datagrid vb6 - 8.68 hr back. (1)
  7. datagridview header column text vertical - 9.05 hr back. (1)
  8. sample code change font on datagridview - 10.97 hr back. (1)
  9. change header datagridview - 14.39 hr back. (1)
  10. datagridview two header lines - 15.94 hr back. (1)
  11. datagridview vertical header - 16.66 hr back. (1)
  12. .net datagridview header text rotation - 22.07 hr back. (1)
  13. flex datagrid "column header text" rotation - 31.46 hr back. (1)
  14. grid for delphi header rotate text - 33.53 hr back. (1)
Similar Topics

Keywords : vertical, text, datagridview, column, header

  1. Updating Values In A Text Box
    (11)
  2. VB.NET: How To Edit & -90degree Rotate Text In Ms Word File ?
    Need reply urgently (3)
    How to open a word file from VB.net? also need to write data in this file with -90 degree rotation.
    just want to add some data in word file through VB.Net but data is needed to be written in -90
    degree rotation format....
  3. Finding The Current Line Number In A Text Box
    A very basic method of doing the deed. (1)
    Language: Visual Basic 6.0 (5.0/4.0) Level: Beginner Problem: How to find the current Line Number
    in a multiline text box? Some times it is necessary for us to provide a text editor in our
    programs, or maybe a text viewer. The text box control has no built in method to find the current
    line number like RichTextBox. Hence we need to code it manually. Solution: The simple concept of
    line numbers is the carriage return character, or simply the ASCII code 10. The line feed character
    has the ASCII code 13. In the code example I have used chr(10), you can also use vbCrLf i....
  4. Visual Basic: Change Your Start Button Text! (XP)
    Windows XP ONLY (16)
    Personally, I love this program I made for myself. What the following code will allow you to do is
    change the text of your start button (Duh). You can make it whatever you want, your name, a hobby,
    or even do some extra programming and get it to randomly cycle through captions every 30 seconds or
    so /smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /> . Here is all the code
    you'll need: CODE Private Const WM_SETTEXT = &HC Private Const WM_GETTEXT = &HD Private
    Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName ....

    1. Looking for vertical, text, datagridview, column, header






*SIMILAR VIDEOS*
Searching Video's for vertical, text, datagridview, column, header
advertisement




Vertical Text In Datagridview Column Header