Questions tagged [datagridview]

DataGridView is a Windows Forms control used to display and edit tabular data.

DataGridView is a Windows Forms control found in the .NET Framework starting at version 2.0. It is used to display and edit tabular data from many different kinds of data sources. It provides a rich set of features such as sorting, filtering, grouping, and editing data.

Useful links

20349 questions
3
votes
4 answers

DataGridView ComboBox column that will accept any text

I want a column of a DataGridView to use a ComboBoxStyle.DropDown style ComboBox, where the user can either select one of the entries in the drop-down, or type arbitrary text. At the moment, I'm using the code from this answer and I can type freely…
Ian Goldby
  • 5,609
  • 1
  • 45
  • 81
3
votes
1 answer

How to select multiple rows OR columns keeping "Ctrl" pressed in DataGridView object

I adapted code from this question how to select rows on cellclick, and also columns on column header click? into a single DataGridView1_MouseDown event, because it wasn't allowing me to select multiple rows/columns using the "Ctrl" key. What I'd…
Zingapuro
  • 51
  • 8
3
votes
1 answer

How to Fill Data Grid View without being my form stop responding?

I'm currently filling my DataGridView using Tasks. At first, when I fill in dataTable, everything is fine, but when I continue to the UI thread, my form is unresponsive for a short time. How can I avoid this unresponsive period? if (bar == null) { …
3
votes
2 answers

How to get a specific cell in a DataGridView on selection changed

With a listbox, I have the following code to extract the item selected: private void inventoryList_SelectedIndexChanged(object sender, EventArgs e) { String s = inventoryList.SelectedItem.ToString(); s = s.Substring(0,…
Elie
  • 13,693
  • 23
  • 74
  • 128
3
votes
2 answers

Add rows programmatically to a DataGridTable

How do I add rows programmatically to a DataGridTable in C#? When the user selects an option, I want to repopulate a DataGridTable with fresh data, which I am acquiring as shown below: connect.Open(); MySqlCommand comm =…
Elie
  • 13,693
  • 23
  • 74
  • 128
3
votes
3 answers

Apply and validate a bound DataGridViewComboBoxCell directly upon selection change

I have a windows forms DataGridView that contains some DataGridViewComboBoxCells that are bound to a source collection using DataSource, DisplayMember and ValueMember properties. Currently the the combobox cell commits the changes (i.e.…
bitbonk
  • 48,890
  • 37
  • 186
  • 278
3
votes
1 answer

WinForms. How to make DataGridView to write cell value when use BindingNavigator

I have WinForms DataGridView and BindingNavigator on the From bind to the same BindingSource. When user enter text into a cell of DataGridView (cell text editor is visible) and press "Move next" in BindingNavigator, it is assumed that the grid…
DmitryB
  • 455
  • 1
  • 5
  • 18
3
votes
1 answer

DataGridView check if any row selected and it's not NewRow

How to check whether user selected row in datagrid view and this row is not newrow? I tried so far this but not working as should: If Not IsNothing(Grid.CurrentRow) And Not Grid.CurrentRow.IsNewRow Then End If First statement seems to works ok but…
user6156963
3
votes
1 answer

Blocked from editing DataGridView record

Is it possible to block duplicate records, but also edit a selected record? I am working on something similar to this. Example When I have numerous records and I update the 2nd or 3rd one, I expect a warning whenever I try to use the first record's…
3
votes
1 answer

Wrap a row in DataGridView

I am trying to create a chatbot. I will be very honest, UI is not my forte. I am working on the backend of the chatbot as in the logic part, but for testing I need a proper working UI. So, I opted for easier to use winforms. I created a single…
KChow
  • 317
  • 3
  • 15
3
votes
1 answer

Update textbox by navigating DataGridView with arrow keys

public delegate void MyEventHandler(object sender, DataGridViewCellEventArgs e); public event MyEventHandler SomethingHappened; private void dataGridViewCargo_CellContentClick_1(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex…
Connor
  • 49
  • 5
3
votes
1 answer

Update datagridview and database vb.net

i want to update my datagridview and also my database im new to vb and i dont know what im doing wrong can sombody help me? Private Sub DataGridView_Booking_Update(sender As Object, e As DataGridViewCellEventArgs) Handles…
Kevin
  • 77
  • 1
  • 9
3
votes
2 answers

Square Filled CheckBox in Datagridview

I have a Database that looks like this Table Name : ri_closure as what you see on the image above all of the columns except Month are TinyInt(1) and Month is Varchar now I have a code here Dim con1 As MySqlConnection = New…
user6825121
3
votes
1 answer

Using SortableBindingList - DataGridView doesn't automatically sort on changes

I'm building a Windows Forms Application that displays a custom class Record objects and sorts them by how long they've been in my SortableBindingList record_list. When I start my program, I have some "dummy" records loaded into this list…
MrDysprosium
  • 489
  • 9
  • 20
3
votes
2 answers

DataGridView Row Color Doesn't Change

Hello im working on Windows Form Applications but i have a problem. We are using data grid view and if row's if one column or more is empty, i want to highlight it. I dont know why but my code doesn't work. Here its my code; public Form1() { …
Berkin
  • 1,565
  • 5
  • 22
  • 48