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

[Solved] Gridview row formatting

2 Answers 162 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Nikk grey
Top achievements
Rank 1
Nikk grey asked on 11 Dec 2009, 12:30 PM
Hi,
I need to change the backcolor, forecolor etc of a complete row.
I dont want to use any events.
I am adding rows to gridview in an event, in whose arguments  i am already supplied with a color. So i just want it like in a standard listview:
this.listviewcontrol.forecolor = color.red;
is this way possible in formatting a row of gridview.
I have already tried 
this.gvTCPIPEvents.Rows[this.gvTCPIPEvents.Rows.Count - 1].VisualElement.ForeColor = e.messageColor;
but nothing happens.
I dont wish to use any of the rowformatting or cellformatting events, as listed on all of the posts.
Any workaround possible.

2 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 11 Dec 2009, 12:59 PM
Hi Nikk grey,

RadGridView
uses UI virtualization of the grid rows and creates visual elements only for the rows that are currently visible on screen. They are reused upon scrolling. That's why you can't set VisualElement.ForeColor directly. You have to handle CellFormatting event in this case. However we plan to extend our API in future and maybe we will add support for setting the BackColor directly through the row object. Could please specify why you don't want to handle one of the formatting events? We will appreciate your feedback.
 
Greetings,
Jack
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
Nikk grey
Top achievements
Rank 1
answered on 11 Dec 2009, 01:24 PM
So,
basically i have to make some kind of condition object and keep a track for it, in order to implement row formatting.

I didn't like those events because of multiple firing on scrolling blah blah blah. My resources are limited and i didn't want to waste much on presentation layer. 
* I am building a set of servers (i.e. TCP/IP, UDP, Serial, and bluetooth) all running simultaneously. They presentation layer utility i am building can be used remotely on a local network and on the host server computer. Using it on the host server causes some strain as it is already computing a lot of data.

my code look like this
        private void MultiParamsUnsafeAddTCPIPEventsGvEntry(InformationReceivedEventArgs e) 
        { 
            try 
            { 
                this.gvTCPIPEvents.Rows.Add(new object[] { e.sentTime.ToLongTimeString(), e.methodType.ToString(), e.reportType.ToString(), e.message }); 
                this.GridViewBestFitColumn(this.gvTCPIPEvents, ContentAlignment.MiddleLeft); 
            } 
            catch (Exception ex) 
            { 
                this.EventReporter.WriteToLog(Source.Application, ex); 
            } 
        } 

where i have supplied some color in event arguments from somewhere the event is firing from.
so what would be my best options now for setting row color for each record, which will retain as it.
Dont want to set them again.
:(
thank you for your support
Tags
GridView
Asked by
Nikk grey
Top achievements
Rank 1
Answers by
Jack
Telerik team
Nikk grey
Top achievements
Rank 1
Share this question
or