Class_LV_Colors > bedingte Formatierung

Stelle Fragen zur Programmierung mit Autohotkey

Moderator: jNizM

Nmk
Posts: 28
Joined: 20 Jan 2017, 19:29

Class_LV_Colors > bedingte Formatierung

10 Apr 2017, 03:07

Guten Morgen,

ich versuche mit mit Hilfe von Class_LV_Colors eine bedingte Formatierung zu basteln. Kann mir jemand sagen, wieso bei meinem Ansatz die Zeile 3,4 und 5 nicht eingefärbt werden?

Code: Select all

; Generated by AutoGUI 1.3.3a
#NoEnv
#SingleInstance Force
SetWorkingDir %A_ScriptDir%

#Include %A_ScriptDir%
#Include lib\Class_LV_Colors.ahk

LV_Data=
(
1;5;1;2;1
1;3;4;2;5
1;2;2;2;3
2;5;5;3;2
1;3;3;3;3
1;4;3;4;3
2;5;5;5;5
2;5;1;4;3
2;2;1;1;1
1;3;2;5;1
3;5;2;3;3
3;1;2;2;3
3;1;3;3;5
)

Gui, Add, DropDownList, x300 y5 w95 gLVFilter, DropDownList||

Gui, Add, ListView, hWndhMGuiLV1 x5 y+5 w390 r13, Team ID|Mark I|Mark II|Mark III|Mark IV|Average
LV_ModifyCol(1, 60), LV_ModifyCol(2, 60), LV_ModifyCol(3, 60), LV_ModifyCol(4, 60), LV_ModifyCol(5, 60), LV_ModifyCol(6, 60)
	
	
	CLV := New LV_Colors(hMGuiLV1, True) ; StaticMode not working.
    LV_DataArray := []
    loop, parse, LV_Data, `n, `r
    {
        LV_DataArray := StrSplit(A_LoopField, ";")
		
		Average := Round((LV_DataArray[2] + LV_DataArray[3] + LV_DataArray[4] + LV_DataArray[5])/4, 2)
		
        LV_Add("", LV_DataArray[1], LV_DataArray[2], LV_DataArray[3], LV_DataArray[4], LV_DataArray[5], Average), LV_ModifyCol(1, "Sort")
		
		CLV.Row(A_Index, 0xFAF305)

    }

	; Gui, Add, Button, x5 y+5 w80 h23 gBT1, &OK
	; Gui, Add, Button, x+5 yp w80 h23 gBT2, &OK
	
	GetFilter()
	
	Gui, Show, w400 h286, Window

Return

LVFilter:
    Gui, Submit, NoHide
    LV_Delete(), LV_DataArray := []
    loop, parse, LV_Data, `n, `r
    {
        LV_DataArray := StrSplit(A_LoopField, ";")
        if (InStr(LV_DataArray[1], A_GuiControl))
            LV_Add("", LV_DataArray[1], LV_DataArray[2], LV_DataArray[3], LV_DataArray[4], LV_DataArray[5]), LV_ModifyCol(1, "Sort")
    }
    GuiControl,, EditEntries, % LV_GetCount()
Return



BT1:
Return

BT2:
Return

GetFilter()
{
	Loop % LV_GetCount()
	{
		LV_GetText(TeamID, A_Index)
		TeamIDS .= TeamID . "|"
	}
	Sort, TeamIDS, D| U
	GuiControl,, ComboBox1, % "|" TeamIDS
}

GuiEscape:
GuiClose:
    ExitApp
	
!r::
AppReload:
	Reload

; Do not edit above this line
In Spalte 6 wird der Durchschnitt berechnet, welcher später die Grundlage für die Formatierung liefern soll.

Gruß

Nmk
just me
Posts: 9451
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Class_LV_Colors > bedingte Formatierung

10 Apr 2017, 04:24

Moin,

ich schätze mal es liegt daran, dass Du das Control nach jedem Hinzufügen einer Zeile sortieren lässt. A_Index in CLV.Row(A_Index, 0xFAF305) muss deshalb nicht mehr mit dem Index der zugefügten Zeile übereinstimmen.

Du solltest erst sortieren, wenn alle Zeilen hinzugefügt sind. Das ist auch 'performanter'.
Nmk
Posts: 28
Joined: 20 Jan 2017, 19:29

Re: Class_LV_Colors > bedingte Formatierung

10 Apr 2017, 06:12

Gut geschätzt:

Code: Select all

; Generated by AutoGUI 1.3.3a
#NoEnv
#SingleInstance Force
SetWorkingDir %A_ScriptDir%

#Include %A_ScriptDir%
#Include lib\Class_LV_Colors.ahk

LV_Data=
(
1;5;1;2;1
1;3;4;2;5
1;2;2;2;3
2;5;5;3;2
1;3;3;3;3
1;4;3;4;3
2;5;5;5;5
2;5;1;4;3
2;2;1;1;1
1;3;2;5;1
3;5;2;3;3
3;1;2;2;3
3;1;3;3;5
)

Gui, Add, DropDownList, x300 y5 w95 gLVFilter, DropDownList||

Gui, Add, ListView, hWndhMGuiLV1 x5 y+5 w390 r13, Team ID|Mark I|Mark II|Mark III|Mark IV|Average
LV_ModifyCol(1, 60), LV_ModifyCol(2, 60), LV_ModifyCol(3, 60), LV_ModifyCol(4, 60), LV_ModifyCol(5, 60), LV_ModifyCol(6, 60)
	
	
	CLV := New LV_Colors(hMGuiLV1, True) ; StaticMode not working.
    LV_DataArray := []
    loop, parse, LV_Data, `n, `r
    {
        LV_DataArray := StrSplit(A_LoopField, ";")
		
		Average := Round((LV_DataArray[2] + LV_DataArray[3] + LV_DataArray[4] + LV_DataArray[5])/4, 2)
		
        LV_Add("", LV_DataArray[1], LV_DataArray[2], LV_DataArray[3], LV_DataArray[4], LV_DataArray[5], Average)
		
		if Average between 0 and 1.5
		{ 
		CLV.Row(A_Index, 0x338833) 
		}
		if Average between 1.6 and 3.0
		{ 
		CLV.Row(A_Index, 0xFFDD33) 
		}
		if Average between 3.1 and 5.0
		{ 
		CLV.Row(A_Index, 0xCC0033) 
		}
		

    }

	; Gui, Add, Button, x5 y+5 w80 h23 gBT1, &OK
	; Gui, Add, Button, x+5 yp w80 h23 gBT2, &OK
	
	GetFilter()
	
	Gui, Show, w400 h286, Window

Return

LVFilter:
    Gui, Submit, NoHide
    LV_Delete(), LV_DataArray := []
    loop, parse, LV_Data, `n, `r
    {
        LV_DataArray := StrSplit(A_LoopField, ";")
        if (InStr(LV_DataArray[1], A_GuiControl))
            LV_Add("", LV_DataArray[1], LV_DataArray[2], LV_DataArray[3], LV_DataArray[4], LV_DataArray[5]), LV_ModifyCol(1, "Sort")
    }
    GuiControl,, EditEntries, % LV_GetCount()
Return


BT1:
Return

BT2:
Return

GetFilter()
{
	Loop % LV_GetCount()
	{
		LV_GetText(TeamID, A_Index)
		TeamIDS .= TeamID . "|"
	}
	Sort, TeamIDS, D| U
	GuiControl,, ComboBox1, % "|" TeamIDS
}

GuiEscape:
GuiClose:
    ExitApp
	
!r::
AppReload:
	Reload

; Do not edit above this line
Vielen vielen Dank für den Hinweis. Mir fehlt offensichtlich noch die Logik dafür. :headwall:

Gruß

Nmk
just me
Posts: 9451
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Class_LV_Colors > bedingte Formatierung

10 Apr 2017, 08:31

Nmk wrote:Mir fehlt offensichtlich noch die Logik dafür. :headwall:
Vielleicht auch nur die Erfahrung mit AHK? ;)
Nmk
Posts: 28
Joined: 20 Jan 2017, 19:29

Re: Class_LV_Colors > bedingte Formatierung

11 Apr 2017, 06:22

just me wrote:
Nmk wrote:Mir fehlt offensichtlich noch die Logik dafür. :headwall:
Vielleicht auch nur die Erfahrung mit AHK? ;)
Dann kann es ja nur besser werden.

Return to “Ich brauche Hilfe”

Who is online

Users browsing this forum: No registered users and 43 guests