This is a migrated thread and some comments may be shown as answers.

Change the cell content at runtime

2 Answers 73 Views
GridView
This is a migrated thread and some comments may be shown as answers.
regis
Top achievements
Rank 1
regis asked on 01 Dec 2009, 09:32 PM
Hi Every one,

I try to find a way to change the content of a cell programmaticaly.
I found this thread:http://www.telerik.com/community/forums/wpf/gridview/change-the-cell-content-at-runtime.aspx

But it doesn't work for me.

my gridview is link to a dataset. when I modify manually the value of the cell through the interface everything is fine. But if I modify it by code, nothing change.

I don't know if a dataset implement INotifyPropertyChanged but how can I have the value change by code.
I also try with using beginedit function and commitedit but still not work

.
Thank you
private void gridMain_MouseDoubleClick(object sender, MouseButtonEventArgs e)  
        {  
 
            GridViewCell currentCell = (GridViewCell) gridMain.CurrentCell;  
 
            if (currentCell.DataColumn.DisplayIndex > 17)  
            {  
                  
                if (currentCell.Foreground == Brushes.Red)  
                {  
                    currentCell.Foreground = Brushes.Black;  
                    currentCell.Value = currentCell.Value.ToString().Replace("*""");  
                }  
                else 
                {  
                    currentCell.Foreground = Brushes.Red;  
                    currentCell.Value = currentCell.Value.ToString() + "*";  
                                                             
                      
                }  
      
            }  
              
        } 

2 Answers, 1 is accepted

Sort by
0
Accepted
Nedyalko Nikolov
Telerik team
answered on 04 Dec 2009, 02:07 PM
Hello regis,

The only way to achieve this is to change properties of the underlying data object. If you use DataTable.DefaultView then you can take the advantage of the INotifyPropertyChanged interface.
Can you provide me with more detailed information about your scenario, so we can think either for a workaround or implement as a built in functionality?

Kind regards,
Nedyalko Nikolov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
regis
Top achievements
Rank 1
answered on 04 Dec 2009, 04:51 PM
Hi Nedyalko,

I already link the defaultview as source for my grid but it didn't help.

I used Vlad answer on the following link:

http://www.telerik.com/community/forums/wpf/gridview/change-the-cell-content-at-runtime.aspx


I am sorry I open a double threads but I was not sure someone would answer on this one as it was checked "answered".

Thank you for your time.
Tags
GridView
Asked by
regis
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
regis
Top achievements
Rank 1
Share this question
or