TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Jyoti Jodha
NA
1.7k
407k
Update values id don't save in database
Apr 25 2017 2:35 AM
int editrowindex=-1;
//addbutton.Text="Add";
private void dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
try
{
var senderGrid = (DataGridView)sender;
if (e.ColumnIndex == dataGridView.Columns["Delete"].Index && e.RowIndex >= 0)
{
dataGridView.Rows.RemoveAt(e.RowIndex);
int i = 1;
foreach (DataGridViewRow g1 in dataGridView.Rows)
{
g1.Cells[0].Value = i;
i++;
}
}
else if (e.ColumnIndex == dataGridView.Columns["Edit"].Index && e.RowIndex >= 0)
{
addbutton.Text = "Update";
editrowindex = e.RowIndex;
comboBoxproduct.Text = "";
comboBoxproduct.SelectedText= dataGridView.Rows[e.RowIndex].Cells[1].Value.ToString();
dectxt.Text = "";
dectxt.Text = dataGridView.Rows[e.RowIndex].Cells[2].Value.ToString();
txtqty.Text = "";
txtqty.Text= dataGridView.Rows[e.RowIndex].Cells[3].Value.ToString();
combounit.Text = "";
combounit.SelectedText = dataGridView.Rows[e.RowIndex].Cells[4].Value.ToString();
qtytxtprice.Text = "";
qtytxtprice.SelectedText = dataGridView.Rows[e.RowIndex].Cells[5].Value.ToString();
txttax.Text = "";
txttax.SelectedValue = dataGridView.Rows[e.RowIndex].Cells[6].Value.ToString();
Totaltxt.Text = "";
Totaltxt.SelectedText = dataGridView.Rows[e.RowIndex].Cells[7].Value.ToString();
}
}
catch { }
}
Reply
Answers (
2
)
How can I change text direction of a column in datagridview?
how to gridview column values alignment change in windows c#