I am using C# in Visual Studio 2010. I have two tabs. In each tab, I have a DataGridView (1 and 2) table with a ComboBoxColumn (1 and 2). I would like to make it so that when the user selects an index from the ComboBoxColumn1 in tab1, tab2 indicates that selection in one of the columns of that DataGridView in text form. Does anyone know how to do this? Any help would be much appreciated.
Thanks
Use the DataGridView.CellValueChanged event to catch the change in DataGridView 1 and then use that value to update DataGridView 2.
Related
i use visual studio 2012 c#. I tried to do something but unfortunately it's not working.
My problem:
I have a form with two datagridviews: one should be master and the other details(clone).
1-) such that When a row is selected in the master datagridview, the detail or clone datagridview is populated with data pertaining to the selected row.
2-) Secondly, What I am want to do is print (display) the master datagridview and each of the corresponding detail datagridviews. My legacy application already has printing capability so I'm trying to use that. I've created an array of the datagridviews and printed them, but all the detail datagridviews are the same because they were copied by reference.
Any help is welcome.
Try using:
currencyManager = (CurrencyManager)dataGridView1.BindingContext[data];
I was wondering 2 things.
How can I make it so when I click on a row it selects both columns?
How can I make it so it auto sorts them when they click a column?
If C# doesn't allow this then is there any libs I could use or anything easier? Thanks.
If you mean your listview has 2 columns and you want to select the both of them on row selection, you can just set FullRowSelect=true.
For your second question check this Sorting ListView Items by Column Using Windows Forms
I have a datagridview with 5 columns. 4 columns are generated from dataset and 5th is the edit column. In the 4th column I need to generate the buttons with text values of the dataset. Can anyone help me in this regard
In the designer you can edit the columns by pressing the little Arrow in the right upper corner.
There add your button column and set the DataPropertyName to the name of the property you are trying to bind to. Leave the UseColumnTextForButtonValue on False.
See screenshot:
Good luck
I'm using Devexpress tool anyone please help me?
I'm using Devexpress tool to develop my website. But i have some problems so i hope anyone could help me. I really need it in my project. Please see here:
http://www.fiditour.com/dattourtructuyen.aspx?id=731
look section above capcha. I have 2 questions:
- How they can add textbox in gridview?
- How they can add new row by value in textbox?
Thank for reading!
That is not textboxes in the grid. They are editable cells.
You can access the values entered by using the handler of the first row, then like #Давид Дача Милинкови mentionned, you add the specified row.
So as to have a textbox inside the column you must insert a GridViewDataTextColumn not just a GridViewDataColumn.
In the CellEditorInitialize event of the Grid you can pass the Default Value to e.Editor.
well i have a program and i developed it by C# and WPF with Visual Studio 2010 ,
i have an window that contains a windows form datagridview (because of use of .Net Framework 3.5 for windows 7 support) i want to user can sort data in datagridview in any style that he/she wants and finally he/she can press enter on a cell of datagridview that he/she selected and then program open an detailed window about that row in datagridview ,
everything went well except one import thing , i use datasource of datagrid in my code like this :
if (gridView.SelectedCells.Count == 0) return;
int index = gridView.SelectedCells[0].RowIndex - 1;
but this doesn't work well because datasource of datagridview did not change even a bit after all of sort working and that is still exactly like before ...
why ? and what can i do for updating this datasource after sorting or any better way to do this ?
Thanks All ,
Kind Regards ,
Omid
It sounds like you're expecting the DataGridView to modify the datasource - which it won't (always) be doing in the case of a sort being performed.
Rather than getting your hands on the selected cell's RowIndex, if you want the underlying data item associated with that row, try getting the "DataBoundItem" from the Row object.