473,378 Members | 1,209 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

sub item in list view item invalid bounds during DrawItem in owner draw

This is just a wierd one... I am trying to draw the sub items in the
drawitem event of the list view in owner drawn mode (because of documented
W32 rendering bugs) instead of in two seperate items drawitem and
drawsubitems... but when I run this code in the drawitems

For Each subItm As ListViewItem.ListViewSubItem In _tn.SubItems

' If subItm..ColumnIndex <0 Then

'If (e.State And Windows.Forms.ListViewItemStates.Selected) = 1 Then

' textColor = Drawing.SystemColors.Window

'Else

' textColor = e.Item.ForeColor

'End If

If _tn.SubItems.IndexOf(subItm) 0 Then

If (e.State And Windows.Forms.ListViewItemStates.Hot) = 0 Then

Debug.WriteLine(String.Format("Left: {0} Index: {1} Text {2}",
subItm.Bounds.Left, _tn.SubItems.IndexOf(subItm), subItm.Text.Trim))

Debug.WriteLine(subItm.Bounds)

e.Graphics.DrawString(subItm.Text, subItm.Font, New
Drawing.SolidBrush(textColor), New Drawing.RectangleF(subItem.Bounds.Left,
subItm.Bounds.Top + ((subItm.Bounds.Height -
CInt(e.Graphics.MeasureString(subItm.Text, subItm.Font).Height)) \ 2),
subItm.Bounds.Width, subItm.Bounds.Height), NodeStringFormat)

Else

If (e.State And Windows.Forms.ListViewItemStates.Selected) =
Windows.Forms.ListViewItemStates.Selected Then

e.Graphics.DrawString(subItm.Text, subItm.Font, New
Drawing.SolidBrush(Drawing.Color.White), New
Drawing.RectangleF(subItm.Bounds.Left, subItm.Bounds.Top +
((subItm.Bounds.Height - CInt(e.Graphics.MeasureString(subItm.Text,
subItm.Font).Height)) \ 2), subItm.Bounds.Width, subItm.Bounds.Height),
NodeStringFormat)

Else

e.Graphics.DrawString(subItm.Text, subItm.Font,
Drawing.SystemBrushes.HotTrack, New
Drawing.RectangleF(subItm.Bounds.Left,subItm.Bound s.Top +
((subItm.Bounds.Height - CInt(e.Graphics.MeasureString(subItm.Text,
subItm.Font).Height)) \ 2), subItm.Bounds.Width, subItm.Bounds.Height),
NodeStringFormat)

End If

End If

End If

Next

End Sub

it fails miserably! My bounds always seem to come out with a bad numberl ike
this

{X=2000815513,Y=17,Width=16,Height=17}

why?! how do i render sub items in the item draw event properly?
Aug 2 '06 #1
0 2275

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

Similar topics

7
by: Devron Blatchford | last post by:
Hi there, I have created an owner draw menu item using DrawItem and MeasureItem in VB.NET. This seems to work well. I was wondering how I can do mouse over effects in these menus. Basically the...
2
by: Robin Tucker | last post by:
Is it possible to embed controls within a listbox item? I'm currently owner-drawing a list box - but I would like to have controls embedded in each list item. Is this possible, or am I in cloud...
2
by: Richard Wilde | last post by:
I am trying to change a colour of a listbox item depending on a value in a data view My fields in the dataview are ID Name idCat ListBox1.ValueMember = "ID" ListBox1.DataSource = dv1...
2
by: Thomas E. Nørgaard | last post by:
Hey guys! Does anyone know how to get the value of the highlighted item when the combobox is dropped down and the cursor is hovering over the item? Thanks! Best Regards Thomas
1
by: HKSHK | last post by:
Hi guys, I have a problem with the combo box I'm writing on. What I want is custom items, which are fine so far, but when I select one the combo box shows the project name...
0
by: Staz003 | last post by:
Hey guys, So here i've got this treeview that i owner draw the text, mainly to put it over 2 lines and put some additionnal icons in there, my problem is the side scrolling. You see when you...
2
by: sukhjinder | last post by:
want to Draw a Custom Background for the selected Item Here is what I've tried MyListBox() //Constructor { this.SetStyle(ControlStyles.DoubleBuffer, true);...
3
by: CSharper | last post by:
Is it possible to selectivly change the color of an item in text. I saw ForeColor option, but it changes the color of all the items. If it is not possible, is there any other control list listbox...
1
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hello, I would like to keep passwords in a ListView item but have them display as asterisks or som other arbitrary character. This is easy in a text box by settin the appropriate attribute but...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.