|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Centering a datagrid's column headersHow do you center the text in the column headers of a datagird? Using vb
6.0 and the standard Datagrid > How do you center the text in the column headers of a I don't do database programming, so I've never used the Datagrid control. > datagird? Using vb 6.0 and the standard Datagrid However, if you click on Custom in the Properties Box and click the Layout tab, it looks like you can set the Align property for each column individually. I'm guessing if you select 2-dbgCenter, it will center the column header and its data. Give it a try, it might do what you want. Rick That doesn't work... the grid is bound to a recordset. When I treid your
method I kept getting index out of bounds errors. I don't believe this is the way to accompliish this task. Show quoteHide quote "Rick Rothstein (MVP - VB)" <rickNOSPAMnews@NOSPAMcomcast.net> wrote in message news:O1%23cJg2WHHA.1208@TK2MSFTNGP03.phx.gbl... >> How do you center the text in the column headers of a >> datagird? Using vb 6.0 and the standard Datagrid > > I don't do database programming, so I've never used the Datagrid control. > However, if you click on Custom in the Properties Box and click the Layout > tab, it looks like you can set the Align property for each column > individually. I'm guessing if you select 2-dbgCenter, it will center the > column header and its data. Give it a try, it might do what you want. > > Rick > >>> How do you center the text in the column headers of a Okay, try it in code this way...>>> datagird? Using vb 6.0 and the standard Datagrid >> >> I don't do database programming, so I've never used the Datagrid control. >> However, if you click on Custom in the Properties Box and click the >> Layout tab, it looks like you can set the Align property for each column >> individually. I'm guessing if you select 2-dbgCenter, it will center the >> column header and its data. Give it a try, it might do what you want. > > That doesn't work... the grid is bound to a recordset. When I treid your > method I kept getting index out of bounds errors. I don't believe this is > the way to accompliish this task. DataGrid1.Columns(N).Alignment = dbgCenter where N is the column number (substitute your actual control name for the DataGrid1 name I used). Rick I tried that and that just centers the data in the cell not the column
headers :( Show quoteHide quote "Rick Rothstein (MVP - VB)" <rickNOSPAMnews@NOSPAMcomcast.net> wrote in message news:OgDGZ%232WHHA.4872@TK2MSFTNGP03.phx.gbl... >>>> How do you center the text in the column headers of a >>>> datagird? Using vb 6.0 and the standard Datagrid >>> >>> I don't do database programming, so I've never used the Datagrid >>> control. However, if you click on Custom in the Properties Box and click >>> the Layout tab, it looks like you can set the Align property for each >>> column individually. I'm guessing if you select 2-dbgCenter, it will >>> center the column header and its data. Give it a try, it might do what >>> you want. >> >> That doesn't work... the grid is bound to a recordset. When I treid your >> method I kept getting index out of bounds errors. I don't believe this >> is the way to accompliish this task. > > Okay, try it in code this way... > > DataGrid1.Columns(N).Alignment = dbgCenter > > where N is the column number (substitute your actual control name for the > DataGrid1 name I used). > > Rick > >
Show quote
Hide quote
>>>>> How do you center the text in the column headers of a This is probably a completely wrong way to do it, but I tried this without >>>>> datagird? Using vb 6.0 and the standard Datagrid >>>> >>>> I don't do database programming, so I've never used the Datagrid >>>> control. However, if you click on Custom in the Properties Box and >>>> click the Layout tab, it looks like you can set the Align property for >>>> each column individually. I'm guessing if you select 2-dbgCenter, it >>>> will center the column header and its data. Give it a try, it might do >>>> what you want. >>> >>> That doesn't work... the grid is bound to a recordset. When I treid >>> your method I kept getting index out of bounds errors. I don't believe >>> this is the way to accompliish this task. >> >> Okay, try it in code this way... >> >> DataGrid1.Columns(N).Alignment = dbgCenter >> >> where N is the column number (substitute your actual control name for the >> DataGrid1 name I used). > >I tried that and that just centers the data in the cell not the column >headers :( connecting to any database and it seemed to work... Dim W As Long Dim SpaceWidth As Long Dim NumOfSpaces As Long Dim ColumnHeaderText As String ColumnHeaderText = "Hello" With DataGrid1 SpaceWidth = Me.TextWidth(" ") W = .Columns(1).Width NumOfSpaces = (W - Me.TextWidth(ColumnHeaderText)) \ SpaceWidth \ 2 .Columns(1).Caption = Space$(NumOfSpaces) & ColumnHeaderText End With Rick
Within a *.exe
Function that returns an Array Reason for 'Set' keyword SendKeys command fails on Vista Error in reading large csv file Should I or shouldn't I include excel.exe in my app distribution package? Cannot quit Excel called from VB6 Source Control via Network Drive Getting Info from a .TTF File Run-time Error 430, WITH non-broken binary compatibility? |
|||||||||||||||||||||||