473,698 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Custom draw/highlight color

I'm trying to change highlight color af a ListItem
Here's my function
Private Sub ListViewCustomD raw(ByRef m As System.Windows. Forms.Message)

Dim lvcd As NMLVCUSTOMDRAW

Dim oListViewItemEx As ListViewItemEx

'Get lvcd structure

lvcd = CType(m.GetLPar am(lvcd.GetType ), NMLVCUSTOMDRAW)

Select Case lvcd.nmcd.dwDra wStage

Case ApiEnum.CustomD rawDrawStage.PR EPAINT

m.Result = New
IntPtr(ApiEnum. CustomDrawRetur nFlags.NOTIFYIT EMDRAW)

Case (ApiEnum.Custom DrawDrawStage.I TEMPREPAINT)

'Ask to notify postPaint and subitem

m.Result = New
IntPtr(ApiEnum. CustomDrawRetur nFlags.NOTIFYSU BITEMDRAW Or
ApiEnum.CustomD rawReturnFlags. NOTIFYPOSTPAINT )

Case (ApiEnum.Custom DrawDrawStage.I TEMPREPAINT Or
ApiEnum.CustomD rawDrawStage.SU BITEM)

oListViewItemEx = MyBase.Items(lv cd.nmcd.dwItemS pec)

If Not oListViewItemEx Is Nothing Then

If oListViewItemEx .Selected Then

lvcd.clrTextBk = 15718086

'Don't draw as selected

lvcd.nmcd.uItem State = ApiEnum.CustomD rawItemState.GR AYED

m.Result = New IntPtr(ApiEnum. CustomDrawRetur nFlags.NEWFONT)

End If

End If

Case ApiEnum.CustomD rawDrawStage.IT EMPOSTPAINT

DrawItemLines(l vcd)

m.Result = New IntPtr(ApiEnum. CustomDrawRetur nFlags.DODEFAUL T)
End Select

End Sub

The problem is both lvcd.clrTextBk and lvcd.nmcd.uItem State have no effect

Can't understand why. I did something like that in vb6 without problems

Thanks

Stefano Baldi


Nov 20 '05 #1
1 2188
Hi,

Maybe this will help
http://www.codeproject.net/cs/miscctrl/customheader.asp

Ken
---------------------
"Stefano Baldi" <sb**********@a ruba.it> wrote in message
news:OH******** ******@TK2MSFTN GP12.phx.gbl...
I'm trying to change highlight color af a ListItem
Here's my function
Private Sub ListViewCustomD raw(ByRef m As System.Windows. Forms.Message)

Dim lvcd As NMLVCUSTOMDRAW

Dim oListViewItemEx As ListViewItemEx

'Get lvcd structure

lvcd = CType(m.GetLPar am(lvcd.GetType ), NMLVCUSTOMDRAW)

Select Case lvcd.nmcd.dwDra wStage

Case ApiEnum.CustomD rawDrawStage.PR EPAINT

m.Result = New
IntPtr(ApiEnum. CustomDrawRetur nFlags.NOTIFYIT EMDRAW)

Case (ApiEnum.Custom DrawDrawStage.I TEMPREPAINT)

'Ask to notify postPaint and subitem

m.Result = New
IntPtr(ApiEnum. CustomDrawRetur nFlags.NOTIFYSU BITEMDRAW Or
ApiEnum.CustomD rawReturnFlags. NOTIFYPOSTPAINT )

Case (ApiEnum.Custom DrawDrawStage.I TEMPREPAINT Or
ApiEnum.CustomD rawDrawStage.SU BITEM)

oListViewItemEx = MyBase.Items(lv cd.nmcd.dwItemS pec)

If Not oListViewItemEx Is Nothing Then

If oListViewItemEx .Selected Then

lvcd.clrTextBk = 15718086

'Don't draw as selected

lvcd.nmcd.uItem State = ApiEnum.CustomD rawItemState.GR AYED

m.Result = New IntPtr(ApiEnum. CustomDrawRetur nFlags.NEWFONT)
End If

End If

Case ApiEnum.CustomD rawDrawStage.IT EMPOSTPAINT

DrawItemLines(l vcd)

m.Result = New IntPtr(ApiEnum. CustomDrawRetur nFlags.DODEFAUL T)
End Select

End Sub

The problem is both lvcd.clrTextBk and lvcd.nmcd.uItem State have no effect
Can't understand why. I did something like that in vb6 without problems

Thanks

Stefano Baldi

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
334
by: Steve | last post by:
I have created a transparent custom drawn treeview in c#(using lots of native code as well) that has a bitmap for its background. As well as that, I have created a custom highlight that is a different shape than the default treeview selection highlight. I catch NM_CUSTOMDRAW and in the CDDS_PREPAINT draw stage, I draw the bitmap and return the result CDRF_NOTIFYITEMDRAW In the CDDS_ITEMPREPAINT drawstage I set the background mode to...
0
934
by: Piotrek Stachowicz | last post by:
Hi, Just one more question about owner draw menus. How can I get rid of this nasty standard highlight bar, and instead draw it by myself? When I receive the drawItem event I can check whether the state is selected or not, and I thought that I could draw nice bounding rectangle (instead of the bar). Unfortunately I can't ,because the standard highlight bar is still there...). Piotrek
2
2394
by: Benny Raymond | last post by:
More problems with this... When I run this code, the main form returns an invalid cast exception as it's executing the line "TreeNode n = (TreeNode) this.Nodes;" Does anyone know what would cause this? I just want to be able to use my own node class so that I can store extra data... =========================
5
12488
by: Brian Keating EI9FXB | last post by:
Hello there, Wonder can anyone point me in the correct direction? I would like to change the standard list view control so that i can have alternated rows in a different color, i.e. white grey white grey And I'd also like to change the color or the first colmn. What is the best approach for same? thanks Brian
4
1436
by: Jason Perry | last post by:
Hey Gang, I'm writing my first custom component and am trying to add the text that describes the custom properties. I'm talking about the text that displays in the property inspector (design time) when you highlight a property, in the bottom box that describes what it is for. I've tried: /// <value>This is my property</value>
15
10940
by: Tinus | last post by:
Hello all, I've created a custom control that draws a monthly schedule (using the Draw function in C#). Basically it draws 31 boxes and writes the day number in every box. This works great. But I now want to show a different tooltip for every day. For now I found out that I can add a tooltip for the entire custom control
4
2321
by: Alvo von Cossel I | last post by:
hi, i have been asked to make a good-looking app for a friend. i have an options form with a big tabstrip in it. 1. how can i customize it e.g. change from the standard system style tabcontrol to what i want? 2. if #1 isnt possible to do, what would be the best way to make something look like a tabstrip?
3
7221
by: Arnold the Aardvark | last post by:
I am creating a custom draw tree view based on CTreeCtrl. When the control is re-sized the background is blanked completely, resulting in a horrible flicker. I've seen various suggestions involving the use of double buffering. Those are fine but I want to understand what is wrong. When I created the same control in C++Builder the view was totally flicker free, so this must be something the framework does (or doesn't).
1
3565
by: Robin Tucker | last post by:
Hi ppl, My owner draw list box controls do not "refresh" old selected items when a new selection is made. This means that as you click to make selections, the previously selected items stay highlighted along with the new ones too. It draws correctly when I minimize the window and then maximise it again, but I just don't seem to be getting a "DrawItem" event for switching of an item from Selected to NotSelected! Any ideas??? Here is...
1
8895
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4369
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2330
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.