about repositoryItemCheckEdit - c#

I've added repositoryItemCheckEdit in a xtragrid control's column. And i'm having total 3 columns in my xtragridview. From which two columns will be filled with the help of fields from my table when i'm setting datasource property of gridcontrol.
problem which is i'm facing is that when i'm changing the status of checkbox from xtragrid to checked for one time it works but when i'm checking from next row that time the previous selection of checkbox from gridview lost. It only maintain for only one row. and i want it two remain for multiple row.
how to do this?
my datatable contains two fields as TemplateTitle & TemplateBody. And my xtragrid contains three columns as two from datatable & additional column as a repositoryItemCheckEdit which is unbound column. I created columns of gridview at design time. and i've set just datasource property of gridcontrol to datatable.
thanks.

If the repositoryItemCheckEdit is unbound you have to control the CheckEdit's checked state manually using the grid's CustomUnboundColumnData event otherwise the state is lost when you move to a different row.
You must search DevExpress support center for these type of issues. These are pretty well documented and can be found easily there.
http://www.devexpress.com/Support/Center/p/B135631.aspx
http://www.devexpress.com/Support/Center/p/Q254784.aspx

Using BindingList and not DataTable or ObservableCollection solves the problem for booleans bound to a checkbox in a (DevExpress) GridView/GridControl ( Windows Forms ).

Related

Telerik WPF RadGridView CellEditEnded event issue

I am using Telerik RadGridView for WPF to display the data.
My requirement is when I end up changing a value in one of the columns then update the data of different columns of same row.
I am using CellEditEnded event to calculate and update other cell's value.
This works when I set the focus to any other cell of different row but if I click somewhere in the cells of same row, it does not update values.
Found the solution. Just added grid.Items.CommitEdit().

Equivalent for DataGrid RowDetails template in Winforms DatagridView

I need to create an expander in my datagridview that adds additional info about that row to the datagridview when selected, and hides the same when collapsed.
This is possible by creating RowDetails templates in WPF, but can I do something similar in winforms datagridview? A workaround I'd thought of was dynamically adding objects to the datagridview on expand/collapse, but it won't work in this case because the number, type, arrangement of columns is very different for the details rows than the data rows.
Can RowTemplate possibly help? All examples I've seen thus far use rowtemplate only to fix height, width etc of rows in a datagridview and nothing else.
You can use ToolTip for selected row if you want to show additional data info.

DomainUpDown control inside the GridView

I want to add DomainUpDown control inside a DataGridView as a separate column. Each time a new row is added, I want that DomainUpDown control also be added. I also want to know when the user click the DomainUp or DomainDown button in DomainUpDown control for each row. Is it possible or not? I am using language vb.net/C#. I want to do this in winform not in ASP. Any help or suggestion please!!!
All you need to do/know is how to add an unbound column to an already data bound DataGridView, because from your description you are trying to add a column to a grid which already contains other data bound columns. In fact it would be easier if you had such column in the DataTable, also because with unbound columns you need to make a slightly bigger effort to populate and save the data from/to somewhere.
anyway it should be possible, MSDN explains it here: How to: Add an Unbound Column to a Data-Bound Windows Forms DataGridView Control

Customise a bound datagridview

Howdy, using vs2008 winforms.
I want to be able to use a slightly customised datagridview but cant think of a way to do it.
i have
1. a sqldataadaptor fill a dataset
2. a binding source bound to the dataset
3 a datagridview with the bindingsource set as the datasource.
I want the binding to allow sync between the dataset and datagridview, so i can edit data and then update to database with sqldataadaptor. update.
I want to show some custom columns that are calculated results.
And i want to show a final bottom row that is totals of all the columns in the DVG.
My problem is once the DGV is bound i cant add a custom column or row, it wont let me.
I know i could add it directly to the dataset that is the underlying datasource but then by changing the structure of the dataset i cant update to a database once edits have taken place.
or can i ???
Can someone tell me how i can add my custom columns and a final total row to a bound DGV.
Also while im here, if i click on the top of a column to sort on it, in a bound DGV, will it also re-sort the underlying dataset, so i i edit things will still stay synced ?
thanks in advance for any help
Yes, you can.
The adapter does not care about structure. It only cares about column names used in the Select/Insert/Update/Delete commands. You can add custom columns, expression columns, columns for subtotals, columns for totals, or whatever you need. Even change the order of the columns. I do advise adding a sort column, so you can keep the custom rows in the proper place when you or the user sorts.
You can do the same thing for custom rows. When you update through the adapter, you handle the RowUpdating event and set the SqlRowUpdatingEventArgs.Status to SkipCurrentRow for these custom rows. I strongly advise creating a row type column so you know which rows to skip when updating. (You can also use the sort column's value as a key to skip rows.)
There are a couple of articles on MSDN or KB that illustrate how to add total rows.
"How to sum the fields in a Windows Forms DataGrid control and then display the calculated totals in a footer by using Visual Basic .NET" at http://support.microsoft.com/kb/836672.
In my experience, manipulate the data table first before binding. Do what you need to do in order to support the grid and the grid's interface. It is okay to manipulate the data, add/change/remove columns and rows, then rebind when needed.
To be able to add additional unbound columns to your DataGridView you could also set its AutoGenerateColumns property to false and then add custom columns with the following method:
dataGridView->Columns->Add(...)
To calculate the contents of the unbound columns you can handle the CellValueNeeded and CellValuePushed events but you must set the DataGridView into 'virtual mode' by setting the VirtualMode property to true in order for the eventhandlers to be invoked.
Hope this helps a little....

How to control Column Type in DataGridView that is bound to a CustomObject?

I have a DataGridView in a C# WinForms app that is DataBound at runtime (through Form_Load) to a custom Object.
In the design view of the DataGridView I have no columns set up.
When the Form loads the the columns are automatically created based on the data in the Custom object that it is DataBound to.
My question is how can I control the the Columns that are automatically created.
For example if I want one of the columns to be a DataGridViewLinkColumn instead of the DataGridViewTextBoxColumn that is automatically created?
The default columns are based on the data-type. I haven't checked, but for a link you could try exposing the data as Uri, but that might be hopeful. Really, if you want a specific type of column - add the columns through code and set DataGridView.AutoGenerateColumns to false.
As Andrew implies; normally something like reflection is used to generate the columns, and you'll get a column for every (browsable + public + readable) property. There is a layer of abstraction on top of this if you need, but this won't help with adding a hyperlink column.
You can pre-create your columns in the designer. If the name of the column matches the name of the property the column will end up bound to, the databinding will take care of the DGV population for you as before.

Categories

Resources