Click here to Skip to main content
15,882,278 members
Home / Discussions / Visual Basic
   

Visual Basic

 
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 
GeneralRe: DrawItem for flagged listbox item? Pin
Sonhospa12-Jul-09 7:25
Sonhospa12-Jul-09 7:25 
QuestionRead selected Excel data into DataGridView using VB.NET2008 Pin
drexler_kk11-Jul-09 21:58
drexler_kk11-Jul-09 21:58 
AnswerRe: Read selected Excel data into DataGridView using VB.NET2008 Pin
dan!sh 11-Jul-09 22:34
professional dan!sh 11-Jul-09 22:34 
QuestionRe: Read selected Excel data into DataGridView using VB.NET2008 Pin
drexler_kk11-Jul-09 22:51
drexler_kk11-Jul-09 22:51 
AnswerRe: Read selected Excel data into DataGridView using VB.NET2008 Pin
dan!sh 11-Jul-09 23:47
professional dan!sh 11-Jul-09 23:47 
AnswerRe: Read selected Excel data into DataGridView using VB.NET2008 Pin
helelark12311-Jul-09 23:52
helelark12311-Jul-09 23:52 
QuestionRe: Read selected Excel data into DataGridView using VB.NET2008 Pin
drexler_kk12-Jul-09 0:17
drexler_kk12-Jul-09 0:17 
AnswerRe: Read selected Excel data into DataGridView using VB.NET2008 Pin
Paramu197312-Jul-09 0:29
Paramu197312-Jul-09 0:29 
QuestionRe: Read selected Excel data into DataGridView using VB.NET2008 Pin
drexler_kk12-Jul-09 0:38
drexler_kk12-Jul-09 0:38 
AnswerRe: Read selected Excel data into DataGridView using VB.NET2008 [modified] Pin
helelark12312-Jul-09 0:49
helelark12312-Jul-09 0:49 
QuestionRe: Read selected Excel data into DataGridView using VB.NET2008 Pin
drexler_kk12-Jul-09 0:54
drexler_kk12-Jul-09 0:54 
AnswerRe: Read selected Excel data into DataGridView using VB.NET2008 Pin
helelark12312-Jul-09 0:56
helelark12312-Jul-09 0:56 
QuestionRe: Read selected Excel data into DataGridView using VB.NET2008 Pin
drexler_kk12-Jul-09 1:21
drexler_kk12-Jul-09 1:21 
AnswerRe: Read selected Excel data into DataGridView using VB.NET2008 Pin
helelark12312-Jul-09 1:24
helelark12312-Jul-09 1:24 
QuestionRe: Read selected Excel data into DataGridView using VB.NET2008 Pin
drexler_kk12-Jul-09 1:42
drexler_kk12-Jul-09 1:42 

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.