Moin,
ich habe dir da mal was gebaut, zwei Makros,
S_Insert_Backgroundcolor und
S_Insert_Backgroundcolor_on_Rowchange.
Binde
S_Insert_Backgroundcolor bei jedem
Textfeld, dass eingefärbt werden soll, an das Ereignis
Modifiziert.
Damit sich die Feldfarben bei einem Datensatzwechsel auch anpassen, binde
S_Insert_Backgroundcolor_on_Rowchange an das
Formularereignis
Nach dem Datensatzwechsel
Möchtest Du, das die Hintergrundfarbe des Textfeldes angepasst wird, schreibe in die Zusatzinformation (engl.: tag) ein
B für
Background, läßt du die Zusatzinformation leer, wird die Schriftfarbe angepasst.
Die Farben stehen ganz oben, es gilt, um sie aus RGB zu errechnen, die Formel
z.B. für Rot -> RGB(255, 0, 0)
Code: Alles auswählen
=>
N_rot = (255 * 256^2) + (0 * 256) + (0)
N_rot = 16711680
Code: Alles auswählen
const C_N = 16711680 'rot
const C_O = 16744960 'orange
const C_Y = 39168 'grün
const C_S = 13882323 'grau
Sub S_Insert_Backgroundcolor(event, optional oControl)
if ismissing(oControl) then
ocontrol = event.source.model
endif
select case ocontrol.CurrentValue
case "no"
nBackgroundcolor = C_N
nTextColor = C_N
case "ongoing"
nBackgroundcolor = C_O
nTextColor = C_O
case "yes"
nBackgroundcolor = C_Y
nTextColor = C_Y
case else
nBackgroundcolor = C_S
nTextColor = 0
end select
if ocontrol.tag = "B" then
ocontrol.Backgroundcolor = nBackgroundcolor
else
ocontrol.TextColor = nTextColor
endif
thiscomponent.modified = false
End Sub
sub S_Insert_Backgroundcolor_on_Rowchange(event)
oForm = event.source
for i = 0 to oform.count - 1
oControl = oForm(i)
if oControl.supportsservice("com.sun.star.form.binding.BindableDatabaseTextField") then
if ubound(oForm.getScriptEvents(i))>= 0 then
oscripts = oform.getScriptEvents(i)
if oscripts(0).ScriptCode="vnd.sun.star.script:Standard.States.S_Insert_Backgroundcolor?language=Basic&location=document" then
S_Insert_Backgroundcolor(event,oControl)
endif
endif
endif
next i
end sub
Anbei eine Beispieldatei.
So, viel Erfolg
Gruß R