Click here to Skip to main content
15,920,053 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Print Dialog Pin
Luc Pattyn13-Jul-09 12:31
sitebuilderLuc Pattyn13-Jul-09 12:31 
QuestionA narrow width combo box on the toolstrip control Pin
jinxster12-Jul-09 22:04
professionaljinxster12-Jul-09 22:04 
AnswerRe: A narrow width combo box on the toolstrip control Pin
dan!sh 12-Jul-09 22:12
professional dan!sh 12-Jul-09 22:12 
GeneralRe: A narrow width combo box on the toolstrip control Pin
jinxster13-Jul-09 2:11
professionaljinxster13-Jul-09 2:11 
GeneralRe: A narrow width combo box on the toolstrip control Pin
dan!sh 13-Jul-09 3:14
professional dan!sh 13-Jul-09 3:14 
Questionchange the size of playing video in window media player Pin
bhumika_singh12-Jul-09 21:56
bhumika_singh12-Jul-09 21:56 
AnswerRe: change the size of playing video in window media player Pin
Dave Kreskowiak13-Jul-09 1:49
mveDave Kreskowiak13-Jul-09 1:49 
GeneralRe: change the size of playing video in window media player Pin
bhumika_singh13-Jul-09 2:22
bhumika_singh13-Jul-09 2:22 
GeneralRe: change the size of playing video in window media player Pin
Dave Kreskowiak13-Jul-09 3:59
mveDave Kreskowiak13-Jul-09 3:59 
Questionwhat is pDllname in this "craxddrt.database.logonserver(pdllname,pservername,pdatabasename,puserid,ppassword)" ? [modified] Pin
xingselex12-Jul-09 15:36
xingselex12-Jul-09 15:36 
AnswerRe: what is pDllname in this "craxddrt.database.logonserver(pdllname,pservername,pdatabasename,puserid,ppassword)" ? Pin
riced12-Jul-09 21:19
riced12-Jul-09 21:19 
AnswerRe: what is pDllname in this "craxddrt.database.logonserver(pdllname,pservername,pdatabasename,puserid,ppassword)" ? Pin
Jack Vanderhorst13-Jul-09 14:25
Jack Vanderhorst13-Jul-09 14:25 
QuestionIcons to Applicaton Pin
nei200912-Jul-09 9:26
nei200912-Jul-09 9:26 
AnswerRe: Icons to Applicaton Pin
EliottA12-Jul-09 9:40
EliottA12-Jul-09 9:40 
GeneralRe: Icons to Applicaton Pin
nei200912-Jul-09 9:55
nei200912-Jul-09 9:55 
GeneralRe: Icons to Applicaton [modified] Pin
Steven J Jowett12-Jul-09 10:16
Steven J Jowett12-Jul-09 10:16 
GeneralRe: Icons to Applicaton Pin
0x3c013-Jul-09 8:49
0x3c013-Jul-09 8:49 
AnswerRe: Icons to Applicaton Pin
chilinhhacker13-Jul-09 18:09
chilinhhacker13-Jul-09 18:09 
AnswerRe: Icons to Applicaton Pin
Sebastian Br.13-Jul-09 22:08
Sebastian Br.13-Jul-09 22:08 
Questionconfusion in static functions Pin
abcurl12-Jul-09 0:56
abcurl12-Jul-09 0:56 
AnswerRe: confusion in static functions Pin
Christian Graus12-Jul-09 4:34
protectorChristian Graus12-Jul-09 4:34 
AnswerRe: confusion in static functions Pin
nlarson1113-Jul-09 4:00
nlarson1113-Jul-09 4:00 
QuestionDrawItem for flagged listbox item? Pin
Sonhospa12-Jul-09 0:25
Sonhospa12-Jul-09 0:25 
Hello everybody,

I hope someone can help me out with the right idea how to solve a listbox issue. The challenge is to change the color of listbox items depending upon a flag (TRUE if successfully processed). I tried to integrate several snippets already, but there's always something that makes it fail...

Ok.. some important information in advance:
- The listbox 'lstTargetFiles' is bound to a List (Of FileInfo).
- It shows the filenames of all the files in that list.
- Due to databinding issues I can't use a listview control.

For changing the color of successfully processed files in that list I owner-draw the listbox. The drawitem event works fine on initialization:
Private Sub lstTargetFiles_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles lstTargetFiles.DrawItem
        ' Draw the background of the ListBox control for each item. Create a new Brush and
        ' initialize to a Black colored brush by default.
        e.DrawBackground()
        Dim myBrush As Brush = Brushes.Black

        ' Determine the color of the brush to draw each item based on the index of the item to draw.
        Select Case e.Index
            Case 0
                myBrush = Brushes.Red
            Case 1
                myBrush = Brushes.Orange
            Case 2
                myBrush = Brushes.Purple
        End Select

        ' Draw the current item text based on the current Font and the custom brush settings.
        e.Graphics.DrawString((CType(sender, ListBox)).Items(e.Index).ToString(), e.Font, myBrush, e.Bounds, StringFormat.GenericDefault)

        ' If the ListBox has focus, draw a focus rectangle around the selected item.
        e.DrawFocusRectangle()

    End Sub
This results in the first three items colored.

But how can reach my particular goal? Can I pass something like a flag or a user argument which could be triggered? I couldn't even find a way how to raise the event manually when the flag is true...

Thank you for your advice,
Michael
NewsWorkaround: DrawItem for flagged listbox item? Pin
Sonhospa12-Jul-09 2:34
Sonhospa12-Jul-09 2:34 
AnswerRe: DrawItem for flagged listbox item? Pin
Henry Minute12-Jul-09 3:46
Henry Minute12-Jul-09 3:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.