Hello guys
Is there anyway to align the text in msflexgrid in vertical orientation like excel does?
thanks
Hello guys
Is there anyway to align the text in msflexgrid in vertical orientation like excel does?
thanks
Not if you are talking about vertical rotation of text.
You could convert your text into a rotated image and then load the image.
Further on this...
You can print rotated text to a picturebox control and then assign the picturebox to a cell.
This link shows a similar usage of the method but for a slightly different reason.
Nothing built-in, but here is a hack I used a few years back. You pass in a string to the function and it passes back a string with a carriage return and line feed after every character.
Private Function VerticalString(ByVal strInput As String) As String
Dim strReturn As String
Dim i As Integer
For i = 1 To Len(strInput)
strReturn = strReturn & Mid$(strInput, i, 1) & vbCrLf
Next i
If Len(strReturn) > 1 Then
strReturn = Mid$(strReturn, 1, Len(strReturn) - 1)
End If
VerticalString = strReturn
End Function
Private Sub FillGrid()
flexgrid1.TextMatrix(1, 0) = VerticalString("Kc Chiefs")
End Sub
There is a lot to rotating Fonts by 90 degrees. VB6 uses an OLE StdFont object part of the stdole2 type library.
You will have to convert the StdFont into a GDI font to be able to manipulated it.
Here is a very nice post (Text At Any Angle) with sample code to go on doing exactly that.
The sample is drawing on a form, but I would think you can get a handle to a MSFlexGrid and draw into that.
You can then control when and how the text is drawn. If you want to edit the vertical text at runtime, you can show a horizontal textbox over the cell instead while editing the text and then draw the new text when finished editing.