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




How To Change The Column Header Of A Datagrid?


I'm now using a datagrid to show the data of a dataset. However, the column header just shows the field name. How can I change the column header into more meaningful text?

thx~




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Datagrid Column Header
Hi all,
the text I have in my column header for my datagrid is too wide for the column width I am allowed. I have used vbCrlf to wrap the text but then I cannot see the second line in the column header row. Is there a way of setting the height of the column header row? Or alternatively is there a better solution to my problem? Any help would be greatly appreciated.

Datagrid Column Header Alignment
Hello all you VB experts. I have created a VB app that links to an Access table. The data is then linked into the Microsoft DataGrid control. (This is not the MSHFlexgrid control, which took me awhile to disiminate from.) I want to align the column headers either to the right or center. How can I do that? I've looked on numerous web sites, but can't seem to find the answer.

Any help would be great.

-Greg

Sorting Datagrid Column Header
hi,how to sort "ascending 'and "descending" at datagrid column header?thanks fo r help!

How To Return Column Header Name In Datagrid?
I want that, when I double click on a datagrid cell, it will return a msgbox with Column header name (i.e. field name). Like if I write


Code:
msgbox datagrid.text


Then it returns the value of that cell. But I need the column name. Is that possible?

Datagrid First Row Column Header Problem
Hi,

This may be easy, but I can't seem to find the solution.  

When importing a file into a datagrid, I want the user to have the option to choose whether there are column headers in the file.  

If there are no column headers, then I want the datagrid to have default headers, and the 1st row of the input file to show up as the first row in the datagrid.  

The problem is that the first row in the datagrid is blank if I use the following code...

.ConnectionString = "Data Source=D: est.xls;" & _
              "Extended Properties=""Excel 8.0;hdr=no;"""

DataGrid1.ColumnHeaders = True

Why would this be?  Any help that you could give me would be great!  




Sorting Datagrid Column Header
hi,how to sort "ascending 'and "descending" at datagrid column header?thanks for help!

Datagrid Column Header Alignment ...!!!
Dear Friends,

How can I change the Datagrid Column Header Alignment?

Regards,

Sweetie.

Change Column Header's Text
Hello Gurus...

What I have now...
I have a ListView1 in form.
I already fill-in Column Header's Text by using Properties Windows.

What I want to do...
I want to change Column Header's Text by clicking Command1

Code:
Private Sub Command1_Click()
'change 3rd Column Header's Text code goes here

End Sub


Thanks

Changing The Header Of A Datagrid Control Column
plz telll me how to change the column header of a data control

DataGrid Column Header Background Color
anyone know how change the background color of datagrid object ?
I can change the font but i cant change the background color.
Help me please

Wrapping Text In A Datagrid's Column Header
g'morning all!

I have a datagrid that has some column headers coded as so:

With ResultGrid
    .Columns(1).Caption = "Grid" & vbLf & "Position" 'pos
    .Columns(2).Caption = "Name" 'fullname
    .Columns(3).Caption = "Competition" & vbCrLf & "Number" 'comp
    .Columns(4).Caption = "Bike" & vbCrLf & "Size" 'bikesize
    .Columns(5).Caption = "Finish" & vbLf & "Position" 'runfpos
    .Columns(6).Caption = "Status" 'dns

....additional code

end with

I'm trying to wrap the text within the column's header, so that the text appears as:

Competition
  Number

instead of:

Competition Number

I've tried using the "wraptext" property.  It doesn't work (even when used in conjunction with the rowheight property).  As my code testifies, I also tried vbCrLf, and vbLf as well as chr(10) and chr(13) but nothing works.  If anyone has any ideas, I'd really appreciate it.

AMACycle

Datagrid Column Header Display Issue?
Hi all,

I am importing a .csv format file using ADODC into the datagrid control.

I am having column header as 0.3,0.5 in my .csv files.

When i import the same in datagrid, it displays as 0#3,0#5

Can anyone help me out in changing this format?

Using System DSN i have connected. I have given the code as
datagrid1.datasource=adodc1

anything to be changed to get the format? please help me out. It is bit urgent.

Thanks in advance,
dpr

Listview Column Header Color Change?
Hi, I would like to change the color of the column header background color and can't find how to do this. I searched all over on here and PSC. Does anyone know how to do this and have a sample code?

Thanks for your help!

Can You Change The BG Color Of A Listview Column Header
Just wondering if you can if so how. (I'm not looking for how to do it on just your computer but anyone who runs the program. So no control panel thing...)

How To Merge Two Column Header Of A Datagrid, Listview, Or Flexgrid
Good Day to EveryOne!

Can anyone help me how to merge two column header of a datagrid, listview, or flexgrid. Is there a way to have to rows in the header

It should look something like this:

------------
: Range :
: Min : Max :
------------
: 0 : 10 :
.
.
.

Thanks for your reply, in advance!

DATAGRID: Column Autoresizes When Header Is Double-clicked
How can one autoresize the column of a datagrid (according to the width of largest data it contains) when a user double-click not actually the header but between the headers (when the "split" cursor shows, the one with the left and right arrows).... the datagrid control is actually in Visual Basic 6...

---==+ Fear is what keeps us from doing things we know we can't... but we can. +==--- - zhylax

SGrid - How Do I Disable Horizontal Scroll Bar And Change Column Header Color?
I'm currently using SGrid and I need to disable the horizontal scroll bar, and change colours of the Column Header to blue.

Does anyone know which properties or settings that do that?

How To Change Background Color Of Column Header Of Listview In Report Mode?
how can we change listview's columnheaders' backcolor a?
thanks

saracjl

Sabin Kumar Chhetri

Change Datagrid Column Value ???
This is my code




Set rs = New ADODB.Recordset

rs.Open "SELECT id,name,address,male FROM members", cn, 1, 3, 1

Set grdData.DataSource = rs



It's okey but now the column "Male" just show -1 and 0
I want this column will display "Male" or "Female"

I tried this



If rs.Fields("male")=Yes Then

grdData.Columns("male").Text = "Male"

Else

grdData.Columns("male").Text = "Female"

End If



But it don't work..
Thx

How To Change Datagrid's Column Width?
how to change datagrid's column width?

thanks

Datagrid Column Colour Change
Hello!! i need to change the font colour in datagrid ONE column, not in all!!!
EXAMPLE: column1, column2 -The text in column2 must be red!!! )
please help! THANKS!

Change Backcolor Of Column Of Datagrid In Vb6.0
Hi All,

I am working an application of vb6 . In which, i used Datagrid,
i need to change backcolor of particular column of Datagrid.


Pls help me. it's very urgent.

Thanks in Advance,
pradip.

Yahoo! India Matrimony: Find your life partneronline.

How To Change The Column Order Of A Datagrid?
Hello All,

I have searched the forum and found numerous threads on datagrids, but none have had the answer that I seek.

I have a datagrid that shows on my form. This datagrid is used for visual reference only and not to be used by the user.

When I set up my database I listed the members first name 1st and the the last name 2nd and this is the way it shows up on the form.

Now I would like the last name to show up as the first column and the first name as the second column.

I've tried changing the order in the database (access) , but even though in Access this shows up the way I want it to when I run the program it still shows the First name 1st!

Any help would be greatly appreciated.

How To Change Header Colors And Listitem Colors Like Row With Same Color,hide Particular Column In L
How to Change Header Colors and listitem colors like Row with Same color,hide particular column in Listview control

Please Respond ,Urgently

Datagrid: Change Fonts Of A Single Column?
I need to change the font of a single columns in a Datagrid. Unfortunately, there seems to be no easy way to do that. I spent hours on fiddling around with stddataformat - unsuccessful. Has anyone come across this and help me out ? thx.

How I Can Change The Backcolor Of Specific Column In DataGrid
How i can change the Backcolor of specific Column in DataGrid

Getting The Column Header Of The Selected Column In True DBGrid(5.0)
Hi Everyone,
I am new to VB and having a few problems with the code.
I have a true DBGrid(5.0) on a form.When i load the form,i bind the Grid to display values from a table in the Database onto the grid.What I am required to do is to be able to click on any column in the Grid and be able to sort them
(ascending or descending).
I am able to select the whole column by clicking on it.But How do I get the column header or the column number of the column what I select.I will be selecting only one column at a time. I tried finding the values of the column selected by using
colnumber =TestGrid1.Col in TestGrid1_Click event but it is not giving me the correct answer.
Could anyone help me with this...
Thanks,
--Veda

Dynamically Selecting Column By Excel Column Header (B, C... AD, AE, Etc...)
Hi Guys,

I am trying to automate a spreadsheet which would copy values from one worksheet, and insert it into another after manipulating the values slightly. I have managed most of the code (as shown below), however, I am struggling with the following:

The spreadsheet contains pricing information per supplier, and my aim is to retrieve the part number, size, and cost per part from the original into a new worksheet. As the cost column may be in a different location (based on multiple suppliers in the same worksheet), i need to prompt the user for the worksheet that contains the information and the column that contains the costs. I have already written the code to parse the worksheets and populate the combo box with worksheet names. Once a worksheet is selected, I need to parse all used columns and populate a combo box with the Excel column headers (e.g. B, C... AX, BE, etc...) so that the user can choose the correct column. Once the column is selected, I need to convert the column header to a column number (e.g. Col A = 1, Col F=6, Col BC = 46) so that I can copy the values via the GetRows() subroutine in the code.

Any help would be appreciated. Included below is the code that I have thusfar...

Thanks

-------------------------------------------------------------------------------------------------


Code:
Private Sub Worksheet_Activate()

' Get number of worksheets in workbook
cboWorksheet.Clear

' Get names of worksheets in workbook
For iCnt = 1 To ActiveWorkbook.Worksheets.Count
    If ActiveWorkbook.Sheets(iCnt).Name <> "Data Unload" Then
        cboWorksheet.AddItem ActiveWorkbook.Sheets(iCnt).Name
    End If
Next

End Sub

Private Sub GetRows()

' Setup variables to be used
Dim strNewPart, strNewSize, strSheetName As String
Dim iRowData, sRowData, x, y As Integer


strSheetName = cboWorksheet.Text
    
For i = 1 To ActiveWorkbook.Worksheets.Count
    If ActiveWorkbook.Sheets(i).Name = strSheetName Then
        x = i
    End If
    
    If ActiveWorkbook.Sheets(i).Name = "Data Unload" Then
        y = i
    End If
Next
    
    
'Setup Variables in Use
iLastRow = ActiveWorkbook.Sheets(x).Cells.Find("*", , xlFormulas, , xlRows, xlPrevious).Row
sRowData = 6
Debug.Print "iLastRow = " & iLastRow
Debug.Print "sRowData = " & sRowData

       ' Loop through the data table and compare each record with data in the lookup table
       ' If a match is found, change the data table with what is in the lookup table
       For iRowData = 8 To iLastRow
           If Worksheets(x).Cells(iRowData, 1).Value <> "" Then
              
              If Worksheets(x).Name = "Product X" Then
                  strNewPart = Worksheets(x).Cells(iRowData, 1).Value & "X"
                  strNewSize = "0.0"
              Else
                  strNewPart = Worksheets(x).Cells(iRowData, 1).Value & "Z"
                  strNewSize = "0.0"
              End If
              
              Worksheets(y).Cells(sRowData, 1).Value = strNewPart
              Worksheets(y).Cells(sRowData, 2).Value = strNewSize
              
           End If
       
       'increment Unload Counter
       sRowData = sRowData + 1

       Next

       Worksheets(y).Select

End Sub

How To Pop Up The Column Header Name?
How to pop up the column header name from listview and also its data type?My listview name is listview1. I know I have to loop the column header. Then how to get the header name? Have example to go futher?

Column Header
I am using a list view control, with data displayed in several columns. Using API calls I am able to sort records by column by clicking on the particular column header once.
I want to position a combo box on the column header, so that when i click it, all values contained in the combo box are displayed and I can choose any one value. On choosing any value all rows containing that value are only displayed.

Column Header
How can I capture right-click on the ListView column header? Please help
Thanks
Sigal Laniado

Column Header
Hello,
Is there a event which traps the change in column header at runtime in a ListView?
Regards,
Amruta.

Newline In Column Header
Hi, Need help in this area...

.Col = 6
.RowHeight(0) = .Height / 2
.ColWidth(6) = .Width / 7
.CellFontSize = 10
.CellFontBold = True
.MergeCol(0) = "true"
.Text = "Total Moves" & vbCrLf & "(Offloading/Mounting)"

I wanted to create a newline in column header as to minimize the colomn width... I tried using vbCrLf and vbNewLine. But both did not work for me...

Any experts? Please kindly help! Thank you Thank you...

MSHFlexGrid Column Header
Is it possible to make a column header stay on top even when you scroll down?


Thanks

he9ap00

Listview Column Header
I use the columnclick event to sort a column in a listview.
The problem is instead of sorting like this: 1,2,3,4,5,6,7,8,9,10,11... it sorts like this: 1,10,11,12,13,2,3
How can I "fix" this?
----------------------------------------------------
Private Sub lvw1_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
lvw1.SortOrder = lvwAscending
...
----------------------------------------------------

Combo Box In Column Header
I have some data displayed on the form in five different columns. I want to have a combo box on top of each column header. Each combo box holds the value of that particular column. When I choose any value from one combo box, only rows matching that value are displayed.
Is there any way I can do the same using VB6

Combo Box In Column Header
I have a listveiw control on a form with data displayed on it. I would like to put a combo box on the column header so that I can select a particular value from it. Only rows containing the value in that column will be displayed.

Listview Column Header
I have listview with A, B, C column header..This column were added using code.

How to show only the column header A and C in the listview?

Code:
Dim Col As ColumnHeader
For i = 0 To (pFields.FieldCount - 1)

Set pField = pFields.Field(i)

Set Col = ListView1.ColumnHeaders.Add()
Col.Text = pField.Name

Next i

Column Header Size
I try to set the width for column header with equal size except for first column header. Code below size all column header width with same equal size. How to do that?


Code:
'loop to the column size with same value for search listview by code
Dim L As Integer
For L = 1 To ListView1.ColumnHeaders.Count
ListView1.ColumnHeaders(L).Width = 5000
Next L

Listview Column Header
I am looking for a different way to indicate by which column the listview was sorted on other than having an image appear in the Column Header. Does anyone have any ideas on what things I could do?

Thanks!

Column Header In Listview
How do I add a header called "Files" to a listview control

Listview Column Header
How do i put one of those column headers in a listview control, like in Outlook Express, that sorts the column contents??
I know how to sort, so u don't need to write out all of that stuff...

MSHFlexgrid Column Header
good day.

i have a problem regarding transfering data from mshflexgrid to excelfile.
I am able to transfer all the data only.


The column header per record is not included.
Maybe its because in my code i only call the column and rows of themshflexgrid
But i don't know how to refer to the column header.

does somebody know how to do this?please help.

Thanks..



Anna

Column Header Caption !!!
Dear Friend,

How can I change the column header caption? The following code doesn't work:

DataGrid2.ColumnHeaders(1).Caption = invoice
DataGrid2.ColumnHeaders(1) = invoice

PS: Is it possible to change the colour of a single column?

Combo Box In Column Header
I have some data displayed on the form in five different columns. I want to have a combo box on top of each column header.
Each combo box holds the value of that particular column. When I choose any value from one combo box, only rows
matching that value are displayed.

Set Column Header For MshFlexGrid
How can i set the column header for MshFlexGrid?
This is the coding that i used to set the row from my MshFlexGrid.

With MSHFlexGrid1
.Rows = 2
.Cols = 4
.FixedRows = 1
.FixedCols = 0
End With

set MShFlexGrid1.datasource = MyRecordset

Listview Column Header
Hi everyone,

I have a combo box control just above the listview control. When I select the item in the combo box, I change the screen's mousepointer property. When the combo box is in dropped down position, an item's location coincides with the listview control's column header location. This item when selected does not want to change the screen's mouse pointer property. The mouse pointer rests on the column header of the listview when the combo box is closed. Any ideas will be helpful.

Thanks,
Anna

How To Center The Column Header Of MSHFlexGrid?
Hi,

MSHFlexGrid1.ColAlignmentHeader(0, 0) = 4 ' I want to center a column header with this code but it doesn't work. Why?

Another question, what's band?

ListView Column Header Sizing
Hello!

I have a ListView containing two columns which I want to make as big as the whole ListView minus the size of the vertical scroll bar's width (both). Here is what I am using, but it won't work:


Code:
lvwFiles.ColumnHeaders(1).Width = (lvwFiles.Width - GetSystemMetrics(10) * Screen.TwipsPerPixelX) / 2
lvwFiles.ColumnHeaders(2).Width = (lvwFiles.Width - GetSystemMetrics(10) * Screen.TwipsPerPixelX) / 2

Regards,
Sebastian Mares

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