Grid like control with cell level customization for .net - 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.

Related

Custom Dynamic Grid

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

Telerik RadGridView data comparison with cell formatting

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.

Is it possible to add two or more repository controls in devepxress grid control

Hey i am dealing with winform(c#) application. i am using Devexpress Grid Control.
Is it possible to have two or more repository controls in grid control column for edit purpose.
eg.. say like a textbox and combo box in a grid column.(this is possible in web application by adding item templates to the grid column)
Is this possible or any other way to get this done?
You can set the GridColumn.ColumnEdit property to specifying the editor used to edit a column's value

How do I detect when a cell's value has changed in Silverlight?

I'm working in Silverlight, trying to figure out how to set a grid cell font color based on the contents of the cell.
I have an ObservableCollection bound to a DataGrid, and my items implement INotifyPropertyChanged so the grid updates as I change the values; it's all working perfectly, including letting me sort items and keep the sorting while I update the underlying items.
I know I can use the LoadingRow event to change colors, but the only way I can get the event to fire is by changing the grids datasource, in which case my sorting goes out the window.
So, what I really want is a way to either
loop the rows in the datagrid,
find the cell I need, and change
it's color or
implement a custom
column that I can use to dynamically
set the color.
The problem is how to actually do either of those things :).
You should use databinding for this.
Bind your cell font color to the content of the cell
Create a converter IValueConverter that converts the value to a color depending from your needs
See here for a good example
http://weblogs.asp.net/joewrobel/archive/2009/01/25/conditional-formatting-in-the-silverlight-datagrid.aspx

WPF DataGrid - Setting RowDetails programmatically

I'm using the WPF DataGrid, and I'd like to know if there is any way I can access the DataGridRow's RowDetails programatically.
For example, when the user selects the row, I'd to grab some data from somewhere (say, a database), and display it in the RowDetails.
All of the examples I've seen tend to just display some extra bound data that isn't included in the columns for the row.
You could display some extra data but lazy-load it on SelectionChanged.
It usually is not easy to work directly with the WPF controls, they are not really meant to be used without a backing databound model.
If you have all the data in list of objects (or something similar) then you can do all sorts of fun things. I'm using a WPF Datagrid in this manner, and when a user selects a row, I think populate an editor control above the grid with the row item plus additional details.
That said, there's nothing stopping you from adding in additional information in the grid that's normally hidden and a trigger on row selection to show the additional data
you can use the following code
DataRowView row = (DataRowView)MyDataGrid.SelectedItem;
string strName = row.Row["Name"].ToString(); //where "Name" is the column name

Resources