ListBox Heading

Is there a way to center the Heading on a listbox and is there a way to change the background color of the heading cell only, I have tried the following but it changes the cell under the heading.

if row = 0 then g.ForeColor = rgb(225,100,125) else g.ForeColor = RGB(255,255,255) end if g.FillRect 0,0,g.Width,g.Height

Thanks

Use a Canvas to do that. Place it above the ListBox and unset Heading ot the ListBox ?

Search this forum… seems I posted a custom Listbox Header class at somepoint

It can be centered easily if you centre the contents of the entire column. I’d love to see a way to do it for all of the headings though.

www.rdS.com/lb_header.zip

Thanks Dave.

Dave,

I am trying to use your listbox header and the fields are being overwritten within the visible area of my listbox and not the full width of the control. Any tips on fixing this?

The “Folder” and “Parent” columns are the last of the 10 field in my listbox and should be off the screen.

link text

[quote=337988:@Robert Kantor]Dave,

I am trying to use your listbox header and the fields are being overwritten within the visible area of my listbox and not the full width of the control. Any tips on fixing this?

The “Folder” and “Parent” columns are the last of the 10 field in my listbox and should be off the screen.

link text[/quote]

Not sure… The only change I have made to that code in years is to suggest that a line similar to this be added int the CELLBACKGROUNDPAINT event of the actual listbox

If theHEADER.hdr_scrollpositionX<>Me.ScrollPositionX Then theHEADER(0).Refresh

I discovered that it didn’t synch when the listbox scrolled left to right.
other than that I use that control ALOT… as a matter of my current project (TADPOLE) has about 1/2 dozen instances

You DO need to make sure of these things

  • do the ATTACH in the LISTBOX.OPEN event
  • don’t add the header columns until AFTER you have attached it
		lbHeader.attach_to_listbox me
		lbHeader.Add_Header "#"
		lbHeader.Add_Header "Name"
		lbHeader.Add_Header "Type"
		lbHeader.Add_Header "PK"
		lbHeader.Add_Header "AI"
		lbHeader.Add_Header "NN"
		lbHeader.Add_Header "UN"
		lbHeader.Add_Header "CS"
		lbHeader.Add_Header "FK"
		lbHeader.Add_Header "Default"
		//
		me.ColumnType(colSeq) =listbox.TypeNormal
		me.ColumnType(colName)=listbox.TypeNormal
		me.ColumnType(colType)=listbox.TypeNormal
		me.ColumnType(colPK)  =listbox.TypeCheckbox
		me.ColumnType(colAI)  =listbox.TypeCheckbox
		me.ColumnType(colNN)  =listbox.TypeCheckbox
		me.ColumnType(colUN)  =listbox.TypeCheckbox
		me.ColumnType(colCS)  =listbox.TypeCheckbox
		me.ColumnType(colFK)  =listbox.TypeNormal
		me.ColumnType(colDEF) =listbox.TypeNormal
		//
		me.ColumnWidths="30,*,110,32,32,32,32,32,32,*"