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.
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
My title may be unclear for the question that I am asking.
What I have is a DataGrid with 5 rows. Upon resizing the window, the rows of the DataGrid is supposed to fill up the DataGrid space, meaning I want the 5 rows to be split evenly.
I have acheived this by doing the following:
DataGrid1.RowHeight = DataGrid1.RenderSize.Height / 5);
However sometimes when I press the down arrow key on the last row of the DataGrid, It will go down another row, which is an empty space. I would like to prevent that. Any help is greatly appreciated.
This is the datagrid with 5 rows of data.
Before
When I select a cell from the last row and press the down arrow, this is what I get:
After
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.
I have a page that is currently generating dynamically created textboxes in a table format. The users are requesting that the tab order be changed from horizontal-vertical to vertical-horizontal. I know that you can use the tabindex attribute to control the tab ordering, but I can't for the life of me figure out the right way to get the sequential number properly for the textboxes. I guess this is more of a math question than anything else!
FYI, the textboxes are made while looping two different collections. First collection looped to make the rows, for each row, second collection (which is a property of the first collection objects) is looped to create the columns.
Any help would be greatly appreciated. Thanks!
You will need three variables to get this to work:
Total number of rows
Current row index
Current column index
You can then achieve the vertical tab order by setting the tabindex to:
totalRowCount * currentColumnIndex + currentRowIndex + 1
For a five-row, three-column table the above calculation would render the tab order as:
1 5 10
2 6 11
3 7 12
4 8 13
5 9 14
Updated: Wil, thanks for pointing that out. I've updated the example. I also checked the W3C spec (which I probably should have done first) which clarifies the behavior:
elements that do not support the
tabindex attribute or support it and
assign it a value of "0" are navigated
next. These elements are navigated in
the order they appear in the character
stream.
I am using Telerik's WinForms controls and have a radGridView which is bound to a bindingsource to display my data. I would like to expand on the functionality of this a bit to give users an extra way to order the records.
I have added two command buttons to the gridview (Up, Down) to help facilitate this functionality. Basically, when the "Up" button is clicked, I would like the current row to switch places with the row above; if the "Down" button is clicked, the current row should switch places with the row below.
Example data:
1
2
3
4
5
If the "Up" button is clicked on the third row, the data should then look like so:
1
3
2
4
5
If the "Down" button is clicked on the third row, the data should look like this:
1
2
4
3
5
How can I achieve this? Do I have to modifiy the bindingsource positions of these rows, or the gridview row's index? Another way? Any examples are greatly appreciated!
Decided to use drag and drop instead of up/down buttons. All is well.