I need to be able to override the caption colour of a individual row - and have found the following advice:
private void Form1_Load(object sender, System.EventArgs e) { this.ultraGrid1.DrawFilter = new CardCaptionDrawFilter(); } private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { // We must turn off themes on the card captions in order to be able to change their // colors. Otherwise, the themed colors will override the drawing. // ov.CardCaptionAppearance.ThemedElementAlpha = Alpha.Transparent; } public class CardCaptionDrawFilter : IUIElementDrawFilter { #region IUIElementDrawFilter Members bool IUIElementDrawFilter.DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { UltraGridRow row = drawParams.Element.GetContext(typeof(UltraGridRow)) as UltraGridRow; if (row != null) { if ((int)row.Cells["Int32 1"].Value > 5) drawParams.AppearanceData.BackColor = Color.Red; else drawParams.AppearanceData.BackColor = Color.Blue; } return false; } DrawPhase IUIElementDrawFilter.GetPhasesToFilter(ref UIElementDrawParams drawParams) { if (drawParams.Element is CardCaptionUIElement) return DrawPhase.BeforeDrawBackColor; return DrawPhase.None; } #endregion }
How in the name of all that's holy do I begin to translate this to ABL ?
@VisualDesigner. METHOD PRIVATE VOID FooForm_Load( INPUT sender AS System.Object, INPUT e AS System.EventArgs ): THIS-OBJECT:ultraGrid1:DrawFilter = NEW CardCaptionDrawFilter). RETURN. END METHOD.
@VisualDesigner. METHOD PRIVATE VOID ultraGrid1_InitializeLayout( INPUT sender AS System.Object, INPUT e AS Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs ): /* We must turn off themes on the card captions in order to be able to change their colors. Otherwise, the themed colors will override the drawing. */
ov:CardCaptionAppearance:ThemedElementAlpha = Alpha:Transparent. END METHOD. /* stuck here */ public class CardCaptionDrawFilter : IUIElementDrawFilter { /* #region IUIElementDrawFilter Members WHAT DOES THIS MEAN ? */ bool IUIElementDrawFilter.DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { UltraGridRow row = drawParams.Element.GetContext(typeof(UltraGridRow)) as UltraGridRow; if (row != null) { if ((int)row.Cells["Int32 1"].Value > 5) drawParams.AppearanceData.BackColor = Color.Red; else drawParams.AppearanceData.BackColor = Color.Blue; } return false; } DrawPhase IUIElementDrawFilter.GetPhasesToFilter(ref UIElementDrawParams drawParams) { if (drawParams.Element is CardCaptionUIElement) return DrawPhase.BeforeDrawBackColor; return DrawPhase.None; } #endregion }
jmls wrote:
I need to be able to override the caption colour of a individual row - and have found the following advice:
private void Form1_Load(object sender, System.EventArgs e)
{
this.ultraGrid1.DrawFilter = new CardCaptionDrawFilter();
}
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
{
// We must turn off themes on the card captions in order to be able to change their
// colors. Otherwise, the themed colors will override the drawing.
//
ov.CardCaptionAppearance.ThemedElementAlpha = Alpha.Transparent;
}
public class CardCaptionDrawFilter : IUIElementDrawFilter
{
#region IUIElementDrawFilter Members
bool IUIElementDrawFilter.DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams)
{
UltraGridRow row = drawParams.Element.GetContext(typeof(UltraGridRow)) as UltraGridRow;
if (row != null)
{
if ((int)row.Cells["Int32 1"].Value > 5)
drawParams.AppearanceData.BackColor = Color.Red;
else
drawParams.AppearanceData.BackColor = Color.Blue;
}
return false;
}
DrawPhase IUIElementDrawFilter.GetPhasesToFilter(ref UIElementDrawParams drawParams)
{
if (drawParams.Element is CardCaptionUIElement)
return DrawPhase.BeforeDrawBackColor;
return DrawPhase.None;
}
#endregion
}
How in the name of all that's holy do I begin to translate this to ABL ?
@VisualDesigner.
METHOD PRIVATE VOID FooForm_Load( INPUT sender AS System.Object, INPUT e AS System.EventArgs ):
THIS-OBJECT:ultraGrid1:DrawFilter = NEW CardCaptionDrawFilter).
RETURN.
END METHOD.
@VisualDesigner.
METHOD PRIVATE VOID ultraGrid1_InitializeLayout( INPUT sender AS System.Object, INPUT e AS Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs ):
/* We must turn off themes on the card captions in order to be able to change their
colors. Otherwise, the themed colors will override the drawing.
*/
ov:CardCaptionAppearance:ThemedElementAlpha = Alpha:Transparent.
END METHOD.
/* stuck here */
public class CardCaptionDrawFilter : IUIElementDrawFilter
{
/* #region IUIElementDrawFilter Members WHAT DOES THIS MEAN ? */
bool IUIElementDrawFilter.DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams)
{
UltraGridRow row = drawParams.Element.GetContext(typeof(UltraGridRow)) as UltraGridRow;
if (row != null)
{
if ((int)row.Cells["Int32 1"].Value > 5)
drawParams.AppearanceData.BackColor = Color.Red;
else
drawParams.AppearanceData.BackColor = Color.Blue;
}
return false;
}
DrawPhase IUIElementDrawFilter.GetPhasesToFilter(ref UIElementDrawParams drawParams)
{
if (drawParams.Element is CardCaptionUIElement)
return DrawPhase.BeforeDrawBackColor;
return DrawPhase.None;
}
#endregion
}
The #region allows the developer to create foldable code blocks in Visual Studio. /me would love to be able to do the same in VD.
/* stuck here */
public class CardCaptionDrawFilter : IUIElementDrawFilter
{
is the same as the ABL
class CardCaptionDrawFilter implements IUIElementDrawFilter:
It can also mean
class CardCaptionDrawFilter inherits IUIElementDrawFilter:
but since the type begins with "I", I'd assume it's an interface rather than a class.
I think in this case, CardCaptionDrawFilter is probably an internal class, but you should be able make it an "external" class without any hassles.
bool IUIElementDrawFilter.DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams)
The ABL equivalent of the 'ref' keyword in the parameter is 'input-output'.
I had tried to create samples of Create and Draw Filters for the 10.2A samples, but ran into problems (I don't exactly remember what they were). I'd be very interested to hear how you get on.
-- peter
pjudge schrieb:
The #region allows the developer to create foldable code blocks in Visual Studio. /me would love to be able to do the same in VD.
ME TOO!
Stealing Julian's thread - hope he does not mind...
Did you log this already with an internal enhancement request system - or is it worth to log it to the customer ERS?
jmls schrieb:
UltraGridRow row = drawParams.Element.GetContext(typeof(UltraGridRow)) as UltraGridRow;
Peter greatly covered most of the C# to ABL difficulties. However I get asked frequently about the typeof function. The ABL equivalent will be:
Progress.Util.TypeHelper:GetType ("Infragistics.Win.UltraGrid.UltraGridRow") . /* using USING won't help here :-( */
mikefe wrote:
pjudge schrieb:
The #region allows the developer to create foldable code blocks in Visual Studio. /me would love to be able to do the same in VD.
ME TOO!
Stealing Julian's thread - hope he does not mind...
Did you log this already with an internal enhancement request system - or is it worth to log it to the customer ERS?
It never hurts to log it.
-- peter
mikefe wrote:
pjudge schrieb:
The #region allows the developer to create foldable code blocks in Visual Studio. /me would love to be able to do the same in VD.
ME TOO!
Stealing Julian's thread - hope he does not mind...
Did you log this already with an internal enhancement request system - or is it worth to log it to the customer ERS?
ME TOO !
(Stealing my own thread)
Ok, I think we have a problem here. I've done what I need to do, created the appropriate classes etc. However, it doesn't work. The caption colour does not change. I then recreated the project in c# (no mean feat for me, I can tell you ...) and the bloody thing worked.
Could someone compare the two and let me know if it's me or a bug ?
Sorry - what is meant to happen is that i want to change the caption colour of each row. For the purposes of this demo, all captions will be changed to red. However, in the real world I would change each caption to a colour that matches a particular status.
[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/CardCaptionDrawFilter.cls:550:0]
[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/drawfilterdemo.cls:550:0]
[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/drawfilterdemo.resx:550:0]
[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/DrawFilterDemo_2D00_cSharp.zip:550:0]
Ok, I think we have a problem here. I've done what I need to do, created the appropriate classes etc. However, it doesn't work. The caption colour does not change. I then recreated the project in c# (no mean feat for me, I can tell you ...) and the bloody thing worked.
Could someone compare the two and let me know if it's me or a bug ?
Sorry - what is meant to happen is that i want to change the caption colour of each row. For the purposes of this demo, all captions will be changed to red. However, in the real world I would change each caption to a colour that matches a particular status.
I'm (somewhat) glad it's not only me ... I got to the point last night where my code ran but didn't work - which is also what you're seeing.
I would log a bug for this, especially since the code works in C#.
-- peter
W906090149
I don't feel that it does not work at all. I also don't get the effect I'd like to have, but I get different row background for the SalesReps starting with "D".
Basically, I don't get the BeforeDrawBackColor to work - but hte AfterDrawBackColor does. Attached is my drawfilter class. In the AfterDrawBackColor I can change the BackColor using the Rows appearance.
I'm not 100% satified because the background get's back to white when I enter the cells edit mode.
Maybe you've got an idea.
[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/DrawFilter.cls:550:0]
[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/UltraGridDrawFilterForm.cls:550:0]
[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/UltraGridDrawFilterForm.resx:550:0]
Thanks for that Mike. However, it's not the row colour that I am wanting to change, it's the caption color when the grid is in card view mode
Actually, isn't this cheating a bit ? What you are wanting to do can be easily done using the ultraGrid1_InitializeRow event. In fact, I use it to change the colour of a field in the row based on the contents of that field.
Isn't the draw filter a mechanism for drawing "stuff" that isn't handled by the standard control ? Like drawing new icons for sorting on the headers etc etc. That's why the original c# code uses the drawParams:AppearanceData object.
Or am I losing it ?
I don't feel that it does not work at all. I also don't get the effect I'd like to have, but I get different row background for the SalesReps starting with "D".
Basically, I don't get the BeforeDrawBackColor to work - but hte AfterDrawBackColor does. Attached is my drawfilter class. In the AfterDrawBackColor I can change the BackColor using the Rows appearance.
I'm not 100% satified because the background get's back to white when I enter the cells edit mode.
Maybe you've got an idea.
Yeah, there's something funky going on. My understanding is that you update the drawParams:AppearanceData object and it does the trick. You shouldn't need to change the grid/row directly. The attached file manipulates the grid's properties directly - using the AfterDrawBackColor - which sorta-kinda works. If you resize the form, the first record's caption turns blue (instead of red).
The BeforeDrawBackColor doesn't work at all.
[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/3362.form1.cls:550:0]
[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/2402.form1.resx:550:0]
-- peter
jmls schrieb:
Actually, isn't this cheating a bit ?
Probably yes - but at least it verifies that the DrawFilter class and callback are working properly.
Actually, isn't this cheating a bit ? What you are wanting to do can be easily done using the ultraGrid1_InitializeRow event. In fact, I use it to change the colour of a field in the row based on the contents of that field.
I'd think that a bunch of stuff can be handled by the InitializeRow event.
Isn't the draw filter a mechanism for drawing "stuff" that isn't handled by the standard control ?
Not so sure about that.The IG help says ( http://help.infragistics.com/Help/NetAdvantage/WinForms/2009.1/CLR2.0/html/Win_Draw_Filter.html):
An element's appearance can be easily controlled by setting various
properties on Appearance objects exposed by PLF-based controls. However,
occasionally a requirement comes along that isn't supported by the control. This
is where a draw filter is invaluable.
The fact that an AppearanceData object is used seems to indicate that you can do anything you want there
-- peter
Oh, I knew that the code was "working" in that it got to that point - a messagebox in there is quite funky. What I found was that if I said
message "#1" drawParams:AppearanceData:BackColor:ToString() view-as alert-box.
ASSIGN drawParams:AppearanceData:BackColor = System.Drawing.Color:Red.
message "#2" drawParams:AppearanceData:BackColor:ToString() view-as alert-box.
I got
#1 Color [InactiveCaption]
#2 Color [InactiveCaption]
pjudge wrote:
The fact that an AppearanceData object is used seems to indicate that you can do anything you want there
-- peter
Except what I want