|
|
|
| Web Hosting |
![]() ![]() |
Vertical Text In Datagridview Column Header |
Jul 31 2006, 08:09 AM
Post
#1
|
|
|
Newbie [ Level 1 ] Group: Members Posts: 1 Joined: 29-July 06 Member No.: 14,823 |
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 |
|
|
|
Aug 2 2006, 10:54 PM
Post
#2
|
|
|
Super Member Group: [HOSTED] Posts: 567 Joined: 25-April 05 Member No.: 4,374 myCENTs:57.88 |
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 |
|
|
|
Apr 22 2007, 06:08 PM
Post
#3
|
|
|
Newbie [ Level 1 ] Group: Members Posts: 1 Joined: 22-April 07 Member No.: 21,593 |
QUOTE(tomtrak @ Jul 31 2006, 01:39 PM) [snapback]83839[/snapback] 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 |
|
|
|
Aug 29 2007, 05:43 AM
Post
#4
|
|
|
Newbie [ Level 1 ] Group: Members Posts: 4 Joined: 29-August 07 Member No.: 24,443 |
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. 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. This post has been edited by mazel: Aug 29 2007, 05:49 AM |
|
|
|
Aug 30 2007, 03:56 PM
Post
#5
|
|
|
Super Member Group: [HOSTED] Posts: 567 Joined: 25-April 05 Member No.: 4,374 myCENTs:57.88 |
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.
|
|
|
|
Jun 12 2008, 07:16 AM
Post
#6
|
|
|
Newbie [ Level 1 ] Group: Members Posts: 0 Joined: 1-November 07 Member No.: 25,869 |
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 |
|
|
|
Jul 13 2008, 07:33 AM
Post
#7
|
|
|
Newbie [ Level 1 ] Group: Members Posts: 0 Joined: 1-November 07 Member No.: 25,869 |
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 |
|
|
|
![]() ![]() |
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
Similar Topics
| Topic Title | Replies | Topic Starter | Views | Last Action | |||
|---|---|---|---|---|---|---|---|
![]() |
0 | zainboy | 109 | 25th December 2008 - 08:50 PM Last post by: zainboy |
|||
![]() |
14 | Mr 85 | 1,668 | 17th December 2008 - 03:44 PM Last post by: ryantommo |
|||
![]() |
3 | nighthawk16 | 2,262 | 14th December 2008 - 05:51 PM Last post by: iG-Kudos |
|||
![]() |
2 | denverporia19 | 1,872 | 11th December 2008 - 10:36 PM Last post by: iG-Marble |
|||
![]() |
13 | Scionwest | 4,836 | 6th December 2008 - 11:34 PM Last post by: iG-Levi |
|||
![]() |
8 | Mico | 465 | 2nd December 2008 - 07:14 AM Last post by: The_Fury |
|||
![]() |
6 | miCRoSCoPiC^eaRthLinG | 1,993 | 29th November 2008 - 02:24 PM Last post by: yordan |
|||
![]() |
6 | bob3695 | 4,993 | 20th November 2008 - 06:27 AM Last post by: Guest |
|||
![]() |
24 | JohnNitro | 9,673 | 14th November 2008 - 11:54 AM Last post by: Guest |
|||
![]() |
3 | clovis | 1,189 | 13th November 2008 - 05:47 AM Last post by: Guest |
|||
![]() |
2 | merlincsc | 233 | 4th November 2008 - 10:08 PM Last post by: minimcmonkey |
|||
![]() |
6 | Neverseen | 4,574 | 2nd November 2008 - 01:11 PM Last post by: Quatrux |
|||
![]() |
5 | REDMK | 623 | 15th September 2008 - 09:57 PM Last post by: Guest |
|||
![]() |
30 | snutz411 | 3,559 | 11th September 2008 - 11:52 AM Last post by: Guest |
|||
![]() |
7 | TavoxPeru | 969 | 9th September 2008 - 05:18 AM Last post by: Guest |
|||
|
Lo-Fi Version | Time is now: 9th January 2009 - 10:13 AM |
© 2009 AstaHost: Free Web Hosting & Technical Discussion, Free Web Hosting. a member of xisto.
Powered by Invision Board. Skin: IPB Forum Skins
Expand / Collapse Navigation



Jul 31 2006, 08:09 AM





