"Custom" selection mode in DataGridView - c#

I have set up a DataGridView which shows hourly values in a grid (1 column for each day, 24 rows). For my users' convenience, I would like them to be able to easily select a time interval and include all the values in between (see pictures). Preferably via a Shift+Click+DrawMouse operation, or a Click followed by a Shift+Click.
This doesn't seem to be a standard selection mode in DataGridView. Does anyone have a suggestion for solving this?

Related

In ASP.NET web forms is it possible to use RDLC Reports and have the ability to place a tick mark/check mark in cells of a particular column?

I have an RDLC Report Table which retrieves data from a SQL Server.
I've embedded this report into an ASP.NET Web for (.aspx file) using the ReportViewer Control.
When I run the application the Data is retrieved from the SQL Server.
However, I need to have a column where the user has the ability to place a tick mark in the cells of that column.
Obviously I'm able to add a column to the Report itself in the .RDLC file but I'm not able to figure out how to get the tick mark for the user working.
Any ideas how this could be achieved?
Not 100% sure what you mean by:
Obviously I'm able to add a column to the Report itself in the .RDLC file but I'm not able to figure out how to get the tick mark for the user working.
I mean, we don't have a check box control for RDL reports.
And RDL seems to struggle with boolean values.
However, for given columns?
Add a column to the data source/query - cast the boolean column to number - it will still spit out 0 (false) and 1 (true).
Then in the RDL report, you have two choices:
You can add/drop in a check box image, and display it based on the value of the colum above.
But if you want a check box, and un-checked?
You can drop in a indicator. There are a few built in ones. Pick the one with a check box and a "x" for un-checked. it has a seperator also built in - remove that.
So, you get this:
So, using that indicator - 0 to 0, it will display the X, and for 1 to 1, the check box.
You get this effect:
So, it not sure if you ONLY want a check box for true rows, or you want a check box, and a un-check box as per above. You not limited to using a "indicator" on the report, but it for sure the easy road if you need both check and X.
You also are free to input a image, and only show it as true for the column in question that has true values. However, you can't stuff two images into a single column, so indicator becomes the better choice.
Edit: this is only for display - user can't change these while viewing report.
So to be clear, this gets you display, but does not get or give you ability to check or uncheck the boxes in the report.
If you need that ability I'm afraid you are out of luck.
You might be able to present data in a grid view or better yet a listview, allow users to check/ uncheck and then have a view report button.
This also suggests that the data has an extra column for this purpose.
I don't believe that rdl reports have this interactive ability

C# selected calendar days into datagridview columns

I'm creating this function for my attendance monitoring system, now I want to have a datagridview (or if you can suggest some other way) that will show the school days based on the calendar (with out sat. and sun.)
Similar to this, the highlighted part:
As columns and it will change depending on the filter that I select in my combobox.
e.g. I selected January and only the school days of January will be the header.
I just have these 2 questions:
1. How can I make the selected days (of month selected in combobox) to headers of column.
2. what will be my datasource? should I create a database for it?
Help me out, I can't quite get the logic needed here.

how to get 2 lines in datagrid or which control to use in Winforms. so in stead of 1 line use 2 line

I like to have 2 lines (rows) in datagrid, which is together. So normally in a grid you have 1 line per row and every next line/row is independent... But I like to have 2 lines. e.g. 1st row the name,address and 2nd line some amounts, or dates.... so every 2 line is together..
what control do I need to use in Winforms to achieve this... I'm newbie, so I prefer simple solution...
e.g. below I like to use (amount fields should be shown on next line in Datagrid)
DocNumber DocType DueDate SupplierNo SupplierName
Amount VATAmount Total Amount
10000 SA 01-05-2012 1025 Supplier-A
12.25 0.25 12.25
10001 SA 12-12-2014 1095 Supplier-B
42.25 5.25 47.00
10002 SB 31-11-2012 1099 Supplier-C
152.25 55.25 192.00
You could add an extra column to your data (i.e DataTable, for instance) where you specify the row order, and then hide it in your control (a DataGridView for instance).
However this has several drawbacks the first one that comes to mind is that if you click on column headers to sort the grid contents, it will not preserve the order of your rows.
Hope this helps.
Well sounds like to me you need to "group" your data if that's what I'm reading right.
However if this is the case I'm afraid Winforms DGVs do not support this as default as far as my understanding is.
I found this link but havent tried it, looks to be a possible work around/hack for it.
Group Functionality for Winforms Datagridviews
On the plus side there are alot of 3rd party options such as:
Telerik Controls
Or my Personnel favorite :
DevExpress Controls
Beware though even though u can do trials, You may have to pay for publishing, but worth a look!
Hope this helps!

Allowing user to change column order of the datagrid view

I am using Win forms and have a databound DataGridView which has around 31 columns.
AllowUserToOrderColumn is set to true. But since the number of column is 31 its quite difficult for the user to move columns from one end to another.
so I want to create a form which will display all the columns of the datagridview and with the click of up down button allow them to change the order.
I have named my textBox(readonly) from textbox0 to textbox30.
Is there any way to display the column order in text boxes.
Like when we click EditColumns in the designer view.
Certainly:
Look at the DisplayIndex of the columns -> http://msdn.microsoft.com/en-us/library/wkfe535h.aspx
With this, you should be able to read them and change them by code.

Dynamic DataGrid columns in WPF DataGrid based on the underlying set of data (and their type)

I've got kind of a conceptual question. I am in the process of wrapping some statistics classes I wrote into WPF.
For that I have two DataGrid(-Views, currently in WinForms). In one DataGrid each row represents a column in the other. There I can set-up different variables (as in mathematical/statistical variables) with fields like "Header", "DataType", "ValidationBehaviour", "DisplayType". There I can also set-up how it should be displayed. Some Columns can automatically be set to ComboBoxColumns, some TextBoxColumns, and so on and so forth.
So, now once I've set-up these Columns I can go to the other grid and enter my data. I may, for instance, have generated (in grid 1) one Column called "Annual Gross Salary" with input of numerical values. Another Column called "Education" with "0=NoEducation", "1=College Level", "3=Universitary" etc. These labels are displayed as text in the combobox and my statistics engine behind then selects the respective value (0-3) for calculations (i.e. ordinal, nominal variables).
Sooo. In WinForms I could basically generate all the columns by hand in code and then add my data in the respective cells/rows. Now in WPF I thought that must be easy to realise. However, yesterday I got started with ICustomPropertyDescriptor which (maybe I was too thick) didn't give me the results I was looking for.
Basically, I just need to be able to dynamically generate columns (and rows) with different Layout, Controls (ComboBox, simple Input, DateTimes) based on the data that I have. But I don't really know how to go about it?
So here in summary:
DataGrid 1
Purpose is to display columns that have been specified in DataGrid 2
In rows, the user can add any kind of data in the rows below the columns that is allowed as to the columns specifications
DataGrid 2
Each row in this grid represents a column in DataGrid 1
Contains fields like Name/Header, DataType, Validation Behaviour, Default Value, Data Formatting, etc.
Also contains a function to be able to set-up how it should be displayed. The user can select from, for instance, ComboBoxColumn (and also add the available options), DateTime, normal TextBox, CheckBox etc.
After finishing adding a row it will automatically appear as a new column in DataGrid 1
I'd appreciate any kind of pointer into the right direction. Thanks very, very much in advance! :)
Look up DataTemplates. They do exactly this. The UI is determined by the related type.
Here is an MSDN article...

Categories