Answer the question
In order to leave comments, you need to log in
Working with database in c# windows forms?
There is a database (datagridview) in which there is a column "number of tickets" and "train number", you need to make it so that when you enter the train number in the textbox and when you click on the button in this line, the "number of tickets" decreases. Please, help!)
Answer the question
In order to leave comments, you need to log in
private void button1_Click(object sender, EventArgs e)
{
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (row.Cells[0].Value != null && row.Cells[0].Value.ToString() == textBox1.Text)
{
var ticketsCell = row.Cells[2];
var count = int.Parse(ticketsCell.Value.ToString());
if (count == 0) MessageBox.Show("Нет билетов!");
else ticketsCell.Value = count - 1;
}
}
}
datagridview database? it's more of a control. do you need a mesh filter? Obviously, you need to create a second collection, in which to add data by filter, then connect it as a DataSource to the grid and call ResetBindings() on the latter. it is possible to look towards third-party libraries that implement such filters out of the box .. for example, DevExpress.Grid has built-in filters, it works very fast with large volumes
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question