The title may be a bit confusing, and I'll try my best in trying to explain my problem.
I have a horizontally scrollable datagridview and when I click a button on the menu bar, I want the datagridview to move the view to the specified column, while still having all columns still visible.
So For example I click on Fish, and then the datagridview should scroll/position itself to the first mention of Fish in the columns to show a section of the view all related to Fish, while still maintaining all other columns not related to Fish and viewable.
What I would like to know is, is the moving of the position of the view possible to do? I didn't know what to search up, and more or less the results of the search included re-ordering of the columns, which I do not want.
For a DataGridView with windows form --- give your cell to Particuler Id.
Like you want to assign a one column with Fish then
row.Cells["Name"].Value = Fish.Id;
and then on click event give focus to this id.
Note:- for a better solution post your question with your code.
thanks
Replace fish to your search text and try it.
List<DataGridViewColumn> Cols = dataGridView1.Columns.Cast<DataGridViewColumn>().Where(c => c.HeaderText.Contains("fish")).ToList();
if (Cols.Count > 0)
{
dataGridView1.FirstDisplayedScrollingColumnIndex = Cols[0].Index;
}
Above code will scroll down datagridview horizontally to show searched text in column names.
Related
Hi I'm hoping someone can help,
I have a Data Grid that has X amount of rows and I have a Text Box at the bottom of my form called 'Notes', I want the user to be able to select a row then enter a note within the Text Box and store this so when the user selects a different row the Text Box will be blank available for notes to be added for the new row. Then if the user selects a row that they have added notes to the Text Box will contain those notes.
I hope that makes sense, any ideas on how to approach this would be really appreciated.
Thanks,
Ryan
Thanks to GuidoG I have solved this, just in case anyone else has the same issue what I did was add a data binding to the grid then set the parameters. "Text" is just the property name, MyDataTable is the data source for my grid and "Notes" is the column name.
MyGrid.DataBindings.Add(new Binding("Text", MyDataTable, "Notes"));
I am binding data in a DataTable to a GridView.
The result is a simple table with 5 columns and 3 rows.
What I want to achieve is:
If an user clicks on a cell in the GridView, the selected cell should become editable (with a textbox). In that textbox the user should have to possibility to enter new value and save it to the database.
What I've achieved so far is:
I followed this tutorial: http://www.dotnetlogix.com/Article/aspnet/80/How-to-make-GridView-Individual-Cells-Selectable.html
I managed to make the cells clickable, when clicking the cell the background color becomes red:
With that tutorial I also managed to get the ColumnIndex and RowIndex.
So I was able to do: GridView.SetEditRow(RowIndex);
Then my result became:
This is almost what I want, but not 100%. The SetEditRow edits the whole row, but I need to edit the clicked cell which is based on a row and column index.
Can anyone help me further please?
I've followed some other tutorials as well, but without result.
I tried this a few years ago and ran into a few issues, I don't recall all of them off the top of my head right now. What I ended up doing was using a repeater instead of a gridview to build a table. Since I'm writing the HTML I have more control over things. The table contained both a dig tag for the static value and a text input for the edit value. I used jquery to show and hide when needed. I then used ajax to post the changes back. This was a lot of work, but it ended up working out ok. Hope this helps.
I want to make layout dynamically.
For example, When I drag and drop a image, 1 image appears on the box.
When I drag and drop another image, box divide into 2 box (dynamically divide into two).
My question is, what layout should I use (stack panel, grid, or something else) and How to I make layout dynamically using code?
I know question is a little vague but I'm not so good at WPF so please understand Thx.
I would use a GridView and so you can add column or row.
DataGridViewTextBoxColumn trackPositionTextBox = new DataGridViewTextBoxColumn();
trackPositionTextBox.HeaderText = "Track Postion";
trackPositionTextBox.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridViewSamples.Columns.Add(trackPositionTextBox);
That's to add a Column in a DataGridView.
dataGridViewSamples.Row.Add()
That's to add a row.
I'm also not the best in wpf, but I hope it was helpful.
If you don't need any animation, you could simple add new columns and rows to your WPF-Grid, while drop an image.
Maybe this help you: How to add rows and columns to a WPF Grid programmatically
I am a newb to Infragistics and have the following problem:
I have three UltraGrids on the form, one for each of three tables.
I want a fixed row at the bottom of a each band(for the table it references) so that one could add a new record into this row, like one could do with in MS-Access.
I finally got a "static/fix" row at the bottom of the Grid, but
i can for the love of me figure out how to edit it.
I HAVE DONE EXTENSIVE SEARCHING and even asked the Infragistics
experts over at http://blogs.infragistics.com/forums.... but to no Avail..
When at runtime i select this grey row, the Foreign-key(MainAction's ID field) appears but i cannot enter information into the other fields
To summarize:
I want to be able to edit the grey row at the bottom of each ban and when/if i press enter, it should add it to the database.
Kind Regards
Markus
You should activate the row setting the
grid.DisplayLayout.Override.CellClickActivation = Activation.Edit
or Activation.EditAndSelectText
As a question similar to this question, I also have an application with a DataGridView on it. I would like to position the rows such that a specific row is at the bottom of the visible part of the list.
This is in response to a button click that moves a row down by one. I want to maintain the selection on the row I'm moving (I already have this part working). If there are lots of rows, the selected row might move below the visible area. I want to scroll down until it's at the bottom of the visible area.
There does not appear to be a LastDisplayedScrollingRowIndex companion to FirstDisplayedScrollingRowIndex.
Any ideas? Thanks.
As my own guess, I think I need to use FirstDisplayedScrollingRowIndex and the number of rows visible in the DataGridView to calculate the new FirstDisplayedScrollingRowIndex. Maybe I just need to find out what the NumberOfVisibleRows property is called?
Found it. DisplayedRowCount:
if (dataGridView.FirstDisplayedScrollingRowIndex + dataGridView.DisplayedRowCount(false) <= selectedRowIndex)
{
dataGridView.FirstDisplayedScrollingRowIndex =
selectedRowIndex - dataGridView.DisplayedRowCount(false) + 1;
}
Code tested and working in my own project.
The DisplayedRowCount method will tell you how many rows are displayed on screen. Set the parameter value to true to include partial rows.
var displayedRows = myDataGridView.DisplayedRowCount(false);