I am designing a windows application (C#). I have two datagridviews side by side. I want to allow user to match any single row on the left grid to single row on the right grid. I want that the user should be allowed to match as n number of single rows on the left to that many single rows on the right on one-to-one basis. How do I do it?
What I mean is, I can match 3rd row on the left with 5th row on the right (to form a pair), then match the 4th row on the left to match may 1st row on the right, and so on to form maybe 20 or 30 pairs. But after that hit submit button only once to indicate one batch of job is over.
Anybody any ideas.
Related
In my project I need a control that allows me to enter 2 columns.
First column is an Id Number
Second column is some Text.
Example...
row 1 Id = 1 Text = Day Shift
row 2 Id = 2 Text = Night Shift
But I only want to display the Text Values and then have the user select either Day Shift or Night Shift.
The program can then just lookup the corresponding value (1 or 2) for whatever text they chose.
- In Microsoft Access I would just have used a ComboBox and hidden the first column.
I cannot find anything in Visual Studio 2017 to put on my Windows Form that easily does this.
I want to set it all up at design time and the closest I have come so far is by using a LISTVIEW control using a display type of LIST (I don't want column headers either.
It seems to do what I want except that it always wants me to leave a blank space below my lines of text - presumably for a horizontal scrollbar even though I set it to False in the properties and it does not actually display a scroll bar.
If I resize the ListView control to just be big enough for my two rows of text it tries to display the 2nd row next to the 1st row and still leaves a blank space below the rows.
See the below images, assuming I uploaded them properly, I am totally new to asking questions here.
Is there a way I can achieve this - should I be using a different control?
The closest I came to what I need is the top image
[![enter image description here][1]][1]
Thanks and I hope it all makes sense.
In reply to Harry I added the below...
After adding the ListView control to my form I then clicked on the little arrow selector (in the top right of the ListView control).to bring up the collections list popup box.
It is there I set the view to be ‘List’ so I don’t have to have column header, then I clicked on EDIT ITEMS to get another pop-up screen…Click the [Add] button to add items in the rows.
Then I changed the Text to ‘Day Shift’ for the first member (and ‘Night Shift’ for the second member).
To add values in the rows for the 2nd column I then clicked the SUBITEMS (collection) box in properties to get the next popup…
I then clicked the Add button and created a new Text item (value 1)
and repeated this for the Night Shift member but gave it a value of 2.
These values are to be the actual ID values (in the 2nd column).
Note…
I did create column Headers but setting the View to List means I don’t get them displayed (and don’t want them displayed).
but I did notice that changing the View to List also removes the second column (Id) from the ListView display.
As I don’t need the Id values (1 & 2) displayed I am not going to worry about what happened to them disappearing in the display. All I did, though, was just changed the View from Details to List.
Sorry If I’m misunderstanding you but at this point there is no actual code I am creating, no doubt Visual Studio 2017 does that itself but I am not looking at that. Is that what you needed to see?
Hope this makes better sense though, I did try and include images but the system will not let me do that until my reputation points are higher, sorry.
Thanks
I have a very large dataset(can be up to 3 million items) that I am retrieving on demand based on the scroll position of a grid. This means that I will never have all the items in one collection. But, I need the grid to be interactive and allow the user to scroll as if all the items were in memory.
So, I need a way to set the amount of rows (data items) so that the scroll bar will be the proper size for my database collection. I know the total number of items in the database, so I just need to set the total number of rows in the grid to match that number.
Is there a simple way to do this in WPF with a Datagrid or GridView?
Edit: The important thing is that the scroll bar is properly sized. That way the collection can be indexed based off of it.
Use event handlers for several button controls to make buttons: Next, Previous, First, Last. Parameterise the SQL called by these buttons with firstrow and lastrow inputs say 1 to 10. Each time Next is called, the SQL will spit out the next 10 rows. The rows on the grid per page will be equal to 10 in this case.
I am trying to make a table programatically. So far I have managed to create the table with the relevant number of rows and columns. But the problem is that the cells do not wrap around its contents residing in them.
For example, there is a textbox, the user types something in and that word appears in the table. In my case, if the user typed in 'web', it'll appear, but if they type anything larger than 7 characters, then it does not appear.
I've currently got this in my code:
tableLayoutPanel1.Controls.Clear();
tableLayoutPanel1.ColumnStyles.Clear();
tableLayoutPanel1.RowStyles.Clear();
tableLayoutPanel1.ColumnCount = getNumber();
tableLayoutPanel1.RowCount = courseObj.Level_41.Count;
I've used clear() first to clear the table because I will soon be implementing a delete button next to the words. E.g. the user can press a button next to the relevant word to delete it.
EDIT = fixed it. Had to make the autoSize of my label be true.
So I created a datagrid view with columns that go one through ten and rows that go 1 through 5 incremented .0 1. What I want to be able to do is accept 5 user given inputs and then search the grid and if those 5 inputs are in the same row in any row, highlight that row. I'm just not sure how to get started. A point in the right direction would be great.
Is there any way to catch a break in the table in order to insert a "Continued on next page" row? I've tried checking each row to see if the HeaderFormat is -1 (as I set headers to repeat on subsequent pages), but that doesn't work. I suppose I could count rows and guestimate, but I'd rather have an exact point at which to insert the new row at the bottom of the table before it breaks onto another page.
I found a solution. This post describes how to find the page number from a range. You can call this with the range of a row and check when the page changes. When the page changes go back a row index and add the "Continued..." text.