change datagridrow color after add it
-
hello i would like to change the background of the added row in a datagrid. is there any way to get the added row and change its background? Thanks
-
hello i would like to change the background of the added row in a datagrid. is there any way to get the added row and change its background? Thanks
First please tell us the environment. The answer will be different between Windows and Web
I know the language. I've read a book. - _Madmatt
-
hello i would like to change the background of the added row in a datagrid. is there any way to get the added row and change its background? Thanks
Defender-NF wrote:
is there any way to get the added row and change its background?
Yes. Without some context of what you environment you are trying to run this from, we can't really offer anymore help.
Forgive your enemies - it messes with their heads
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
-
Defender-NF wrote:
is there any way to get the added row and change its background?
Yes. Without some context of what you environment you are trying to run this from, we can't really offer anymore help.
Forgive your enemies - it messes with their heads
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
Ah sorry. I m working on visual studio 2010 ultimate, wpf/c# my datagrid are bound to some generic lists/datasets via simple itemsource-bindings. Thanks
-
Ah sorry. I m working on visual studio 2010 ultimate, wpf/c# my datagrid are bound to some generic lists/datasets via simple itemsource-bindings. Thanks
There are a few ways you could achieve this. Without knowing how you are going to determine what triggers a new colour, I can't be any more specific other than to say that you could look at using a different item template using an ItemTemplateSelector, or you could use a DataTrigger to set the background colour. Either mechanism would suffice.
Forgive your enemies - it messes with their heads
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
-
There are a few ways you could achieve this. Without knowing how you are going to determine what triggers a new colour, I can't be any more specific other than to say that you could look at using a different item template using an ItemTemplateSelector, or you could use a DataTrigger to set the background colour. Either mechanism would suffice.
Forgive your enemies - it messes with their heads
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
Okay, so wich property can i use for the Trigger or the Datatrigger? I mean is there something like "IsAdd" as a property? The only thing i found is "IsEditing" but i wanna the row change its background only if its a "new" row.
-
Okay, so wich property can i use for the Trigger or the Datatrigger? I mean is there something like "IsAdd" as a property? The only thing i found is "IsEditing" but i wanna the row change its background only if its a "new" row.
Defender-NF wrote:
I mean is there something like "IsAdd" as a property?
No. If you think about it, the data grid will treat all rows initially as a new row because it has no interaction with the database. You will have to provide some context for it to be able to figure out what a new row is; for instance, you might have an IsSaved property on your data. The key is to look at the data, rather than at the datagrid for the mechanism to add this.
Forgive your enemies - it messes with their heads
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
-
Defender-NF wrote:
I mean is there something like "IsAdd" as a property?
No. If you think about it, the data grid will treat all rows initially as a new row because it has no interaction with the database. You will have to provide some context for it to be able to figure out what a new row is; for instance, you might have an IsSaved property on your data. The key is to look at the data, rather than at the datagrid for the mechanism to add this.
Forgive your enemies - it messes with their heads
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
Thanks Pete for the Assistance I already have some solutions for this based on my database.. but i dont wanna programm on all my classes/datasets/lists new property just to do this? thats why i m looking on a interface-way to resolve that, or maybe an independency function or something, i tryed for example this:
void la2\_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) { emp.NewRowAfterFiltering = true; } }
NewRowAfterFiltering is a property wich i bound to the the datatriger of the gridrow to change background, but it didnt work.
-
Thanks Pete for the Assistance I already have some solutions for this based on my database.. but i dont wanna programm on all my classes/datasets/lists new property just to do this? thats why i m looking on a interface-way to resolve that, or maybe an independency function or something, i tryed for example this:
void la2\_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) { emp.NewRowAfterFiltering = true; } }
NewRowAfterFiltering is a property wich i bound to the the datatriger of the gridrow to change background, but it didnt work.
ok i got it, but the rowbackground goes to the old value after the header got clicked, any idea how can i get in the way of that? thanks
-
hello i would like to change the background of the added row in a datagrid. is there any way to get the added row and change its background? Thanks
********************************************************************************************* ---------------> .aspx code <------------------------------------------------ ***************************************************************************************** *********************** CSS Code ******************** .tabe_1 { margin:0px; overflow:auto; padding:0px 0px 0px 0px; color:#0F7371; font-weight:bold; line-height:31px; font-size:13px; font-family:Verdana, Arial,sans-serif; background:url(../images/tabe_1_bg.jpg) repeat-x top #F8F8F8; } .tabe_2 { margin:0px; padding:0px; overflow:auto; font-size:17px; height:53px; background:url(../images/rows_bg.png) repeat-x top #F3FDFE; line-height:normal; color:#000000; vertical-align:middle; } .tabe_3 { margin:0px; overflow:auto; padding:0px; font-size:18px; height:33px; background:url(../images/rows_bg1.png) repeat-x top #F8F8F8; line-height:normal; vertical-align:middle; } ********************************************************
-
********************************************************************************************* ---------------> .aspx code <------------------------------------------------ ***************************************************************************************** *********************** CSS Code ******************** .tabe_1 { margin:0px; overflow:auto; padding:0px 0px 0px 0px; color:#0F7371; font-weight:bold; line-height:31px; font-size:13px; font-family:Verdana, Arial,sans-serif; background:url(../images/tabe_1_bg.jpg) repeat-x top #F8F8F8; } .tabe_2 { margin:0px; padding:0px; overflow:auto; font-size:17px; height:53px; background:url(../images/rows_bg.png) repeat-x top #F3FDFE; line-height:normal; color:#000000; vertical-align:middle; } .tabe_3 { margin:0px; overflow:auto; padding:0px; font-size:18px; height:33px; background:url(../images/rows_bg1.png) repeat-x top #F8F8F8; line-height:normal; vertical-align:middle; } ********************************************************
It's a WPF application.
Forgive your enemies - it messes with their heads
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
-
hello i would like to change the background of the added row in a datagrid. is there any way to get the added row and change its background? Thanks
Hi, You can get solution to your problem here to change the background of the added row in a data grid. Using this you can set specific appearance of the element via Appearance property. For instance, Grid.Appearance, Header.Appearance, Column.Appearance, Row.Appearance, Cell.Appearance. Visit here and have a look http://www.dapfor.com/Feature.aspx?id=custom_painting[^]