I have two RadGridViews in my application. Two Grids are pulling the information from two different sources. That information bound to grid view.
Both the sources are of same Type List<MyComplexObject>. Now I wanted to compare these two grids, and color the cells (to Red) in second grid which has the different value.
How can we implement this functionality using Silverlight, C# and Telerik RadGridView?
You could use a Style Selector for the grid you want to have colored in a different way. You would need to prepare a normal cell style and a "Red" cell style as in this example. The article present the complete solution for cell style selector so you will have a full view on how this works. What you would need to do additionaly is to add a property (DependencyProperty) to the style selector to which you would bind the data collection against which you check the cell value validity.
Related
I am trying to display items in a grid however the rows and the columns should be generated dynamically. I actually implemented a custom control that derives from Grid control and provide additional properties such as RowCount.
Here is a picture of the grid generated by my custom control using two dimensinal string array as datasource:
But i think my control consumes more than needed resources because it simply destroys column and row definitions and recreates them. Is there any simpler way to implement that control?
You don't need to create a custom control to do that for you... you can use a standard DataGrid. There have been a number of questions on displaying dynamic data in a DataGrid. Please take a look at some of these posts:
How do I bind a WPF DataGrid to a variable number of columns?
DataGridColumn Binding with Dynamically Generated Data
Visualizing 2D Data in a Table
Displaying multidimensional data in WPF
I am looking for a grid like control either WinForm or WPF.
I have collection of a array of class named PropertyInfo. This class exposes PropertyValue and PropertyType as properties. PropertyValue can be any arbitrary object.This collection of array need to be shown in grid layout , where I need to have control on each cell. For example based on PropertyType , the cell could be combobox or checkbox or hyperlink cell or even could be a readonly. So I need create cells in code-behind by iterating collection and array values in each item.
Other requirements are :
Should be a free or standard .net control.
Should be supported in .net 3.5.
Should support hosting custom control in cell to edit cell value.
Ex: Color Picker to edit color.
Should notify value change to perform extra validations like max
text length or numeric range.
Should allow to retrieve cell values which are modified.
It would be nice if cell properties like border, foreground and
background color can be defined.
In my search I came across WinForm DataGridView. This control is more suitable if data is in DataSet and combobox is available when a column type is DataGridViewComboBoxColumn. Not sure if combobox can be placed randomly in any cell via code. Another control named Sourcegrid is on codeplex. Not sure if it can full fill all above requirements. Please provide suggestions. Thanks in advance.
I have a requirement to display a text in various colors within a datagridview cell.
I mean, within one same cell, I need to use several colors !
Which color is to be applied depends on the value of each character.
Any clue? Is there any other object than the datagridview (like a sort of table for instance)
If I could use several Labels within the cell, it would do the job, but how?
AFAIK you should derive your own label class from label and handle the drawing yourself.
Another approach would be handling the datagridview data binding event and creating as many labels as you need for your cell.
I would go with deriving in this case, since the implementation would consist mostly of pretty basic GDI+ stuff and is more flexible than always creating multiple labels.
Silverlight 4 now provides controls to handle Drag and Drop actions. All the Target Controls seem to inherit from DragDropTarget Like so
public class MyControlDragDropTarget : DragDropTarget<TItemsControlType,TItemsContainerType>
.
.
.
A number of controls have pre-defined DragDropTargets including the DataGrid, ListBox, Panels
Which is all very well, but I want to drag and drop from a grid not a datagrid, and there is no pre-defined one for a normal grid.
I actually want to drag a given row from the grid, but without a Container Type for a Grid I cannot work out how to define a DragDropTarget control for the grid.
Only way I can think is instead of using a grid - I use a listbox (for which there is a DragDropTarget) and then place a StackPanel or Grid in each row (which has one row of 'n' columns)
Anyone got any ideas
Ta in advance
A "normal grid" is simply another form of panel, there is no need for specialised DragDropTarget for the Grid, the existing PanelDragDropTarget is sufficient for a "normal grid".
Its important grasp that the Grid does not support the concept of "rows containing cells containing UI elements". The rows and columns of a Grid are entirely equal and are defined purely for layout purposes. UIElement children of a Grid are laid out entirely independently of each other, there is no concept of a set of values belonging to either a column or a row that can be moved or operated on as a group (like picking up a row and dragging it).
Sounds like you have already got an answer for yourself, use the ListBox instead.
BTW, DragDropTarget isn't provided by Silverlight 4 but rather the Silverlight Toolkit. This is an important distinction because the current quality band assigned to DragDropTarget is "Experimental". You need to think carefully about this if you want to use such code in some production release of your own.
In our WPF application we show a data bound GridView, and one of the grid fields is a filter field which is combination of several sub-fields. In the grid, I show a simple string concatenation of the field, but I want the ToolTip to show a formatted presentation of the filter. The formatted presentation might contain some or all of the filter fields.
I can freely change the class bound to the grid.
Can you recommend a way to bind the ToolTip to the data, by adding some sort of a field, so it is nicely displayed, with multiple lines and indentation? I'd like to avoid specifying all the fields I need in the XAML and hide them based on the data, but I will probably do so if I don't come with a better approach. Another option might be to build the ToolTip structure in code in the ToolTipOpening event. Do you have a better idea?
I was having same scenario and was using DataTrigger in the Tooltip's Style to hide and show fields in tooltip based on their values.