Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Align Text With Column Headings


Good day

I would like to have code to align the text within the headings. I have the following headings :
Name: Surname: Comments:
The code is printing but the text is not aligned especially the comments column where the text sometimes overlaps to the next line.

Thx in advance



bednarjm - move to vb6 forum




Edited by - bednarjm on 7/16/2008 10:49:43 AM




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Aligning Text Within Column Headings
I would like to have code to align the text within the headings. I have the following headings :

Name: Surname: Comments:

The code is printing but the text is not aligned especially the comments column where the text sometimes overlaps to the next line.

Thanx in advance

Flexgrid Column Width And Text Align Problem
Hi,

i have the flexgrid which is not connected to database.I have set the first row with the captions and second onwards rows contain data according to the caption.I want to set the column width that should fit the content of the row and align the text left justified.

i tried :

flexgrid.CellAlignment = vbAlignLeft
flexgrid1.colwidth(0) = len(data)


if any of the experts know ,please help.

Thanks.

---Solved ---How To Set Text In MS FlexGrid Align To Left Or Right In Column ?
How to set data in MS FlexGrid align to left or right in each column ? Thanks

How To Get Column Headings
i am using sql server 2000.

in my application i need to get column name of a table

how can i do that?

i had try sp_columns stored procedure but it gives lot of details out of that i want only one column named COLUMN_NAME which will display only column headings of a table.

plz urgent

advanced thanks.

MshFlexgrid Column Headings
Howdy - I've recently converted one of my apps from RDO to ADO and as such need to convert from MsFlexgrid to MshFlexgrid.

Can anyone tell me how to changed the column headings of my grid? At the moment, by default, they are set to the field names from the database I am extracting the data from, although this means little to the users.

I have tried using the .ColHeader(0) and .ColHeaderCaption(0, 1) properties, as my forum search has suggested, but all this has achieved has been to add a second column heading row to my grid. The top heading remains as it was before.

Any ideas?

Excel Column Headings
Hi,

I'm trying to export data from an ADODB recordset to Excel in Access VBA. I'm able to do this, but I want to put column headings in the first row of cells. I've seen code examples that show how to add values to the A1, B1, C1, ect fields, but they are overwritten when I use the .CopyFromRecorset method. Any suggestions? Ideally I'd like to pull the column headings from the record set field names rather than hard coded values.

Thanks
Charlie

PS - Here's the code I'm using...

Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook, xldata, chrData
Dim xlsheet As Excel.Worksheet, xlName, xlRow, xlClm
Dim xlRS As ADODB.Recordset

'Turn on the hourglass
MsgBox Screen.MousePointer

Screen.MousePointer = 11
DoEvents

'Declare the file name that you want to save
xlName = "c: est.xls"

Set xlApp = New Excel.Application
Set xlBook = xlApp.Workbooks.Add
Set xlsheet = xlBook.Worksheets.Add


xlsheet.Cells.CopyFromRecordset sfrmServersList.Form.Recordset

xlsheet.SaveAs xlName

'Quit the Excel application
xlApp.Quit

'open the workbook
xlApp.Workbooks.Open xlName


Set xlApp = Nothing
Set xlBook = Nothing
Set xlsheet = Nothing

'Turn off the hourglass
Screen.MousePointer = 1

End If

Flexgrid Column Headings
I am having trouble with changing the column headings on a flexgrid. I have done it successfully on others but this one just doesn't work!

Here is the code to change the headers:

fgrdOrders.ColHeaderCaption(0, 0) = "ID"
fgrdOrders.ColHeaderCaption(0, 1) = "Seq ID"
fgrdOrders.ColWidth(1, 0) = 600
fgrdOrders.ColHeaderCaption(0, 2) = "Service Type"
fgrdOrders.ColWidth(2, 0) = 1440
fgrdOrders.ColHeaderCaption(0, 3) = "Order Date"
fgrdOrders.ColWidth(3, 0) = 870
fgrdOrders.ColHeaderCaption(0, 4) = "Ship Date"
fgrdOrders.ColWidth(4, 0) = 870
fgrdOrders.ColHeaderCaption(0, 5) = "Delivery"
fgrdOrders.ColWidth(5, 0) = 2000
fgrdOrders.ColWidth(6) = 0

The column headers box is checked and there is one fixed row as choosen in the property pages.

When I run the program the first row is fixed but shows the headers from the recordset that the grid is populated with. The second row shows the headers that I have set as above. The second row is NOT fixed.

I am using several flexgrids in my program and only have this issue with this one!

Please help,
Gerry

VB Listbox Column Headings
Please Help Me!!! I am trying to create a mutlicolumn listbox but I cannot label the column headings. How do you do that?

Column Headings On A Listbox
Hello there,

I have a listbox with columns (using an API call) what I want to know is how do I add column headings ?

If I use another API call to add a horizontal scrollbar will the headings scroll too ?

Many Thanks
Judda

Printing Column Headings In Intro Vs.net
Hello everyone, I was wondedring if someone could help me wiht this assignment. I'm doing terrible in my intro to programmming class using Visula Basic.net, I dont seem to understand it that much. So anyway, here goes my problem. I need a list box to display headings, such as Age group, Males, Females, %Males, %Females, %Total. So far I have it where I have created the text file and I have coded it so far to read the info in the file once.. as you see below. I cant get ti to align the lines that it produces in the list box right either...

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sr As IO.StreamReader = IO.File.OpenText("A:05USPOPU.txt")
Dim ageGroup As String
Dim males, females, total As Double
Dim fmtStr As String = "{0, -9} {1, 9} {2, 10}"
ageGroup = sr.ReadLine
males = sr.ReadLine
females = sr.ReadLine
ListBox1.Items.Add(String.Format(fmtStr, ageGroup, males, females))
ageGroup = sr.ReadLine
males = sr.ReadLine
females = sr.ReadLine
ListBox1.Items.Add(String.Format(fmtStr, ageGroup, males, females))
ageGroup = sr.ReadLine
males = sr.ReadLine
females = sr.ReadLine
sr.Close()
ListBox1.Items.Add(String.Format(fmtStr, ageGroup, males, females))
End Sub
End Class

I really kinda lost from here, can anyone give me some pointers??
the actual problem reads, "Write a program to produce the table shown in figure 3.29, ( this is the program im trying to make), for each age group the column labeled "%Males" gives the percentage of the people in that age group who are male, same thing for the female group. The Last column gives the percentage in each age group. Note: read the file and add up the data once to obtain the total population, and then read the data again to produce the table."

I would extremely appreciate any help whatsoever. Im not asking you to do my assignment, just help please. Thank You all who read and reply

How To Display Column Headings In MSFlexGrid
I have following coding

Do While Not rs.EOF
grid.AddItem rs("company") & vbTab & rs("url")
rs.MoveNext
Loop

I can display search result in flexgrid.With that i want to display column headings also.How do i do this?

Urgent
Thankx
Shooter

MSFlexGrid - Column Sizes And Headings
hi,
I'm using an MSFlexGrid and I can't work out how to make the columns a specific size - at the moment it only has 10 characters or so and just cuts off the rest, even though the actual grid is bigger (if that makes sense).
Also, can you do something to make the headings bold or something like that so they stand out?
thanks very very much!!

ListView Control And Column Headings????????
Ok, I'm trying to learn how to use the ListView control but i can't figure out how to divide the ListView into columns with heading captions. Just like napsters?!? Any tutorials would also help.

Print Column Headings On Each Page In VB
I am printing a data report from VB6. On each page, I want to print the same description, data, constant parameters and column heading. I do not want to use the Header funtion because it seems to be so complicated. So I tried this code:

PrintHeading:
  iPageNumber = Printer.Page

  'print heading here

  For i = iCurrentData to uBound(strData)
    printer.Print 'go to next line
    
    'try to print heading if next page
    if Printer.Page > iPageNumber then
    iCurrentData = i
    iPageNumber = Printer.Page
    GoTo PrintHeading

    'print data here
    Printer.Print strdata(i)
  Next i

Here is my problem: Every time it starts a new page (not including the first page), it prints the first data on that page BEFORE it prints the heading. How should I debug?

Jeff

Word- List Box Selection And Column Headings
how do I assign a specific text to a list box-column heading?
when I set columnHeads=true I get a list box with an empty heading row

I can easily identify all the selected rows but how can I retrieve the value of an specific column within that selected item. Note: more than one item can be selected

btw. Is there a way to determine how many rows were selected??

Sort FlexGrid By Clicking On Column Headings
Is there anyway to sort the data displayed using a FlexGrid when the user clicks on the column heading?

ie. If there was a recordset of employees with attributes including Last Name, First Name, Hire Date, Birth Date, I want the user to be able to double click 'LastName' and have the grid sortedin alphabetical order.

I'm not too familiar with FlexGrids, but I'm sure there must be a way to do it. Thanks in advance for any assistance!

How To Populate A ListView From A DB Adding Column Headings In Report Style?
I'm currently using ADO to connect to my DB. I want to populate a ListView(Report)with data from a table chosen from a CommonDial. but i don' know how to assign the ColumnHeadings as well as add the data. I want my program to be able to file out all the info in the ListView automaticaly once opened.(Tables I no nothing about?!?)

Vertical Align Text In Text Box / Label Control
I searched on "vertical align" in all forums and did not find this mentioned. (Not that it hasn't been, I just didn't get a hit.)

Anyway, is there a way to vertically align text within a VB 6.0 textbox or label control? (i.e., some programmatic equivalent to the Alignment property) It looks really goofy when the text is crammed against the top of the control ...

Getting some other toolset is not an option. (I am doing this at home for kicks and grins.)

Thanx,

P

Text Align When Outputting To Text File
I have three variables here: item number, description, and price. Each line can be a maximum of 50 characters. I need the first two variables left aligned and the last one right aligned on the same line when outputting to a text file, so it looks like:


Code:
01234567890123456789012345678901234567890123456789
itemno description, color price


I already wrote functions for right alignment but I cannot figure out how to have two different alignments when outputting to the text file on the same line. Anyone have any ideas? Thanks.

Word Text Boxes Align Text?
Is there a way of aligning text to bottom in a text box like you can in the cell of a table?

 

Align In Text Box
hi i have an external file named myfile.txt w/c was properly aligned in two columns now wen extracted try to display iton a textbox the texts were not aligned anymore, i used this code

module:

Public Function Combine(txt As TextBox, Sfile As String)
Dim stxt As String
X = FreeFile
Open App.Path & Sfile For Input As X
txt = StrConv(InputB(LOF(1), 1), vbUnicode)
Close #X
End Function

Text Align API... Help
I am printing text in Picturebox, Unfortunately VB doesn't include text alignment except for label or textbox. But there's API function that can get print text alignment in picture box. Check it out

http://builder.com.com/5100-6228-5421501.html

I added.. Declare Sub SetTextAlign Lib "gdi32" (ByValhDC As Long, ByValwFlags As Long) At very top (Where Option Explicit are) and I get complie error... So I am not sure how to implement it since I am not very familar with API calls, So help me.

Code written already on my form, where do I implement Text Align API function in my form?

Code:
Option Explicit

Private Sub Form_Load()
Picture1.FontBold = True
Picture1.FontSize = 12
Picture1.FontName = "Arial"
Picture1.ForeColor = VbWhite
Picture1.BackColor = vbBlacK

End Sub

Align Text Vertically ?
In any label.caption or txt.text
There is option in Properties windows to align text Horizantly (left , Center,Right) But
But there is no Option seen to Align text Verticaly (Top,Mid,Botom).
If there is no available then how can I do this ?

Align Text In MsFlexGrid
Hi,

i have a problem with flesgrid here:

After loading the data into the flexgrid. i realised that some of the data in the cells are either aligned to the left or right.How can i standardise the alignment of the text in every cells?

Apart from the above, i would also like to know whether can i add rows (flexgrid) using codes rather than specifying in the property? I'll be better if a sample code can be provided.

Thanks a million,friends!

Regards!

Align Text To TextBox
I have a form that has one line of text and a textbox. I would like to align the text to the left of the textbox, and centered vertically to the textbox. Is there a way to do this without typing in coordinates or turning off the snap-to-grid and moving it manually? Or, am I just missing the fact that you can do labels for the textbox itself...and all this is taken care of automatically? Thanks in advance!

Toolbar Text Align Help
hi,

Can someone help me or give some info on how to set the Text alignment on the button to the left in a Toolbar, all I can see is tbrTextAlignBottom and tbrTextAlignRight

using the tbrTextAlignBottom is just totaly usless cos there is like a large gap, and if I use the tbrTextAlignRight it just looks even wose and just makes the buttons looks unnatural as the text is closer to the next button.

is there any API call I can use. or anything else.

How To Align Text In A List Box
hello everyone, below is a screen shot of my program.



The text in the list box is read from a text file when the refresh button is clicked.

What i wish to do is align the text so that it comes under the headings like this: (i edited it in paint to give you gys a visual representation :P)



i have attached the whole vb program so you gys can have a look.

Thank you

Using Space() To Align Text
Is it possible to use Space() to get text to left align with headings? Here is what I'm doing now and the result is shown in the attached file.

VB Code:
strMsg = strMsg & "TAG" & Space(11) & "VARIABLE" & Space(11) & "STATUS" & Space(11) _    & "VALUE" & Space(11) & "UNITS" & Space(11) & "TIME" & vbCrLfstrMsg = strMsg & "27-QAO49D" & Space(11) & "PD Pull Roll" & Space(11) & " " & _    Space(11) & "BREAK SHEET" & Space(11) & " " & Space(11) & "15-Sep-05 12:00:00"

Align Text Verticaly ?
In any label.caption or txt.text
There is option in Properties windows to align text Horizantly(left , Center,Right) But
But there is no Option seen to Align text Verticaly(Top,Mid,Botom).
If there is no available then how can I do this ?

Align Text In A ListBox
Is there an easy way right align text in a listbox? I'm currently using tabs to set the colums, but the columns are left aligned and i need my last colum (Numbers) to line up by decimal. is this possibal?

Thanks,

nathan

To Align The Text Box With The Form.......
Hi everybody,

I have created a notepad application. My problem is whenever i maximize the form the text box on the form does not maximize properly or does not fit to the size of the form. I used the resize event of the form. I assigned the height and the width of the form to the height and width of the textbox. But the scrollbars are not adjusted properly. I want that it should maximize properly or fit to the size of the form and also the scrollbars of the textbox should be visible clearly.

Regards

Samir

Align Text In A Label
Is it possible to set text in a multiline label to justify? I don't want left, right or center alignment.

Thanks

Align Rich Text
Is it possible to align the text in a richtext box center?

Textbox.text Can't Right Align...anyone Know If
this a know bug in visual basic?

is there a work-around?

Align Text In A Message Box
Hey guys. has anybody else tried this? it doesn't work.
strMessage = ""
for x = 1 to 5
strMessage = strMessage & vbCrLf & strArray(x)
For y = 1 to (70 - Len(strArray(x)))
strmessage = strMessage & " "
Next y
strMessage = strMessage & strArray2(x)
Next x
MsgBox(strMessage)

What is this for? It should take these 2 arrays and make even columns out of them. But it doesn't. The number of characters in the first array aren't always the same width and so the second column is not aligned.

Since I won't know what is going to print in this array, I can't "make" it line up.

Any thoughts?


Thanks
wengang

Align Columns In Text Box
I have a text box in which multiple columns of figures are displayed as they are computed within my application. Each column may have a varying number of digits or letters.

I want each column to begin at the same relative position in the text box so visually I don't end up with uneven columns. The right side of each column doesn't matter. I realize the font may contribute to unevenness depending upon the character so which font would give me the best results? I don't have a problem with the hard copy output since I convert the contents of the text box to a file and use tabs in the printed results.

Is there a simple way to do this? If I could use tabs in the text box, it would solve the problem. I suppose a series of text boxes (1 for each column) would also work but that would really be a pain. Since the data may go for many lines, I need to have scroll bars or maybe a picture box would do, using currentx,y. I appreciate any advice or solution.

 

To Align The Text In Richtextbox
hai guys,

I am using the form named as billing repot. In this form,we have print button to pritn the content of the bill details in the richtext box. my code is working fine,but all the details of the bill is to be printed in overwrited format.My ques tion is how to align the space for print the bill details in the rich textbox.



Code:
Public Sub PrintView(title As String, query As String, n As Integer, column As Variant)
Dim rs1 As New ADODB.Recordset
Dim colwidth(7) As Integer
rs1.Open "select b.billno,b.bdate,c.caddr,b.quantity,b.rate,b.discount,b.netamt from billing b,CREGISTER c where b.clientname=c.clientname", con, adOpenDynamic, adLockReadOnly
Dim col, ss, sp, Line As String
Line = String$(99, "_") + vbCrLf + vbCrLf
colwidth(0) = 15
colwidth(1) = 10
colwidth(2) = 35
colwidth(3) = 20
colwidth(4) = 25
colwidth(5) = 30
colwidth(6) = 40
colwidth(7) = 45
col = Space(36)
sp = Space(15)
ss = Space(37)
Dim rs As New ADODB.Recordset
rs.Open query, con, adOpenDynamic, adLockReadOnly
View = ""
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Space(5)

frmprintbill.RichTextBox1.Text = rs1("billno")
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Space(10)
frmprintbill.RichTextBox1.Text = rs1("bdate")
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Space(15)
frmprintbill.RichTextBox1.Text = rs1("caddr")
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Space(20)
frmprintbill.RichTextBox1.Text = rs1("quantity")
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Space(25)
View = View + vbCrLf + vbCrLf + vbCrLf
frmprintbill.RichTextBox1.Text = rs1("rate")
View = View + Space(30)
frmprintbill.RichTextBox1.Text = rs1("discount")
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Space(35)
frmprintbill.RichTextBox1.Text = rs1("netamt")
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Space(40)
View = View + Space$(5) + title + vbCrLf + vbCrLf
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Line
Dim j
For j = 0 To n - 1
    If j = 0 Or j = 1 Then
        LSet col = rs(j)
        View = View + sp + col
    Else
        LSet ss = rs(j)
        View = View + sp + ss
    End If
Next j
View = View + vbCrLf
View = View + Line
While Not rs.EOF
'Dim i
    For i = 0 To n - 1
        If i = 0 Or i = 1 Then
            LSet col = rs(i)
            View = View + sp + col
        Else
            ss = Space(colwidth(i))
            LSet ss = rs(i)
            'View = View + sp + ss
            View = View + ss
        End If
    Next i
    View = View + vbCrLf
    rs.MoveNext
Wend
frmprintbill.Show
End Sub
[code]

Plzzzz trace the code and swend the solution for me.


bye
ram

How To Align Text In RichTextBox
Can anybody help me?

I want to print the text from the richtextbox in the format aligned by the user. How shall i go for it?

Thanks

Vertically Align Label Text
This is probably a really silly question, but is it possible to vertically centre text displayed in a label?
Any help greatly appreciated

How To Align Text In A Flexgrid Cell??
Could anyone plz tell me how to center your text within a cell
in a flexgrid??
I have to do this for a project for school and I can't find it
Please help me out

Align Text To Right Side In Textbox?
hi

I have a textbox (Text1) and have a large amount of text which fills the textbox and beyond.

How do I align this text such that the last character is always aligned to the right of the text box (and is visible)?

cheers

Text Align Property When Unavailable
How can I left-align the caption of a command button? Is there any trick using the API functions?

Align Text Box Array With List Box
I have a list box and wish to be able to enter data to the side of the list box , for each item in the list box
eg
List box                         Text Box
aaaaaaaaaa                       mmmmm
bbbbbbbbbb                       pppppp

I have set the text box up as text1(0)  etc so that i can
create an array beside the list box

Is there any way of getting the depth of the text box = depth of the list box or visa versa.

Or is there any other trick of being able to enter data beside a list box , line by line.

I suppose at a last resort i could put the data to a table and use a data entry box.


Appreciate any help or ideas.


How Do You Align Header Text In A Datagrid?
Is it possible to align text in the headers of a datagrid?

TIA
Deke

Align Text Within Label Or Text Box
Can someone tell me how to vertically align text within a txt box or a label in visual basic 6.

Left Align Text In Command Button?
Can anyone tell me how to left align a command button caption, I thought it would be an easy thing to do, but I can't figure it out.
I know this seems like a stupid question!

Align Text/formating In Excel Sheet Using VB 6
Hi,

I am having a problem with aligning text while creating an Excel sheet from VB 6, I implemented the late binding concept and hence I cannot use any property/method specific to one lib. I started off by referencing Excel 10.0 object lib in my VB project and used some properties and methods to align text and draw borders. But since I used late binding, I am not able to use the same properties. For example,

objExcelApp.Cells(2, 4).HorizontalAlignment = xlVAlignCenter
objExcelSheet.Range("A111").Borders(xlEdgeRight).Color = vbRed

I am getting an error when I run the project which reads "variable not declared/defined" and is pointing to xlVAlignCenter

Are there any other properties/methods I can use to achieve the same without referencing any object libraries in my project. Any help is appreciated.

Thanks in advance
Praveen

Left Align Text In A Command Button?
Can anyone tell me how to left align a command button caption, I thought it would be an easy thing to do, but I can't figure it out.
I know this seems like a stupid question!

API Question: Picture Box Print Text Align
I am printing text in Picturebox, Unfortunately VB doesn't include text alignment except for label or textbox. But there's API function that can get print text alignment in picture box. Check it out

http://builder.com.com/5100-6228-5421501.html

I added.. Declare Sub SetTextAlign Lib "gdi32" (ByValhDC As Long, ByValwFlags As Long) At very top (Where Option Explicit are) and I get complie error... So I am not sure how to implement it since I am not very familar with API calls, So help me.

Code written already on my form, where do I implement Text Align API function in my form?

VB Code:
Option Explicit Private Sub  Form_Load()Picture1.FontBold = TruePicture1.FontSize = 12Picture1.FontName =  "Arial"Picture1.ForeColor = VbWhitePicture1.BackColor  = vbBlacK End Sub

Copyright © 2005-08 www.BigResource.com, All rights reserved