KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

listbox color problem

 
Post new topic   Reply to topic    KiXforms Forum Index -> Starters Code Clinic
View previous topic :: View next topic  
Author Message
newbie
KiXforms Novice
KiXforms Novice


Joined: 28 Aug 2008
Posts: 1

PostPosted: Thu Aug 28, 2008 7:52 am    Post subject: listbox color problem Reply with quote

Hello all,

I try to change the forecolor when I find for example 33 in a line...
But that don't work I don't know why ...

Here my code :

Break On
$file = ReadFile("C:\Temp\somefile.tab")
$System = CreateObject("Kixforms.System")
If NOT $System
$nul= MessageBox("KiXforms.Net Not Initiated. This Script Will Now Close.","Error",16)
Quit()
EndIf

$nul = $System.Application.EnableVisualStyles

$Form1 = $System.Form()
$Form1.FormBorderStyle = 1
$Form1.MaximizeBox = 0
$Form1.StartPosition = 1
$Form1.Size = $System.Size(920,700) ;(Width,Height)
$Form1.Text = "Error report..."

$ListBox1 = $System.ListBox()
$ListBox1.Dock = 5 ;Fill
$ListBox1.HeaderStyle = 1 ;Nonclickable
$ListBox1.Height = 550
$ListBox1.Left = 5
$ListBox1.Top = 10
$ListBox1.Width = 800
$nul = $Form1.Controls.Add($ListBox1)

$lf = chr(10)
$index = 0
For Each $line in $file
$linenumber = $index + 1
If INSTR($line,"33")
$nbre = $nbre + " " + $linenumber
EndIf
$Item = $ListBox1.Items.Add($line)
$index = $index + 1
Next

; That don't work HERE

$nbre = Split($nbre," ")
$index = 1
For Each $element in $ListBox1.Items
If ASCAN($nbre, $index) = "-1"
$element.ForeColor = $System.Color.FromName("Blue")
Else
$element.ForeColor = $System.Color.FromName("Red")
EndIf
$index = $index + 1
Next

$Form1.Show ;Displays the Form
While $Form1.Visible
$Nul = Execute($Form1.DoEvents())
Loop
Exit 0

Function ReadFile($file)

Dim $lf, $f, $_, $t
$lf=chr(10)
$f=freefilehandle
$_=open($f,$file)
if @error exit @error endif
do $t=$t+$lf+readline($f) until @error
$_=close($f)
$ReadFile=split(substr($t,2),$lf)

EndFunction

Could you help me ?

Regards.

JF
Back to top
View user's profile Send private message
benny69
KiXforms Advocate
KiXforms Advocate


Joined: 30 Oct 2003
Posts: 567
Location: Lincoln, Ne

PostPosted: Thu Aug 28, 2008 12:58 pm    Post subject: Reply with quote

Hi and welcome to the board,

I don't think it's posable to set each line's forecolor different. I beleive that you can only set the forecolor of the listbox its self

_________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Starters Code Clinic All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group