hi i have a problem with datagridview. I have about 5 datagridviews displaying different items. Now my issue is that how will i know which datagridview the user selected and add from that datagridview only? at the moment the user can add from different datagridviews because the first row of every datagridview is selected. Is it possible to remove the highlighter row of a datagridview
I also tried using FirstDisplayedCell but doesn't work either.
can anyone help me pls?
foreach (DataGridViewRow drv in dgvSoftDrinks.SelectedRows)
That depends on what code you are running and where you are running it, we can offer more specific help if you can be more specific about what you are trying to achieve.
You can use the datagridview's many events to run code. If you want to do something when a user clicks a cell then place the code in the CellClick event, alternatively you have the SelectionChanged event if you want to process code when the user selects a row.
Check out the MSDN page for all the members of the datagridview class or look at the events in the properties tab (go to Properties pane in VS and click on the lightning bolt symbol at the top).
By using the events of a specific datagridview you will know which datagridview the user interacted with.
hi thanks for your reply. i want that in the data grid view on grid view load the first cell is highlighted. i need to disable that highlighed cell. (no highlighted row (showing in blue at the first row))
Use dataGridView1.ClearSelection() to ensure no rows are selected. Depending on how your data is loaded either use it in the Form Load event after you have populated the datagridview or in the DataBindingComplete event.