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
George William
NA
10
1.1k
Editing a cell in a selected datagrid view.
Jan 30 2021 11:46 AM
I am trying to develope an application that opens csv file with 4 colums. Having 3 colums read only, I want to edit the csv file's fouth column after save the file.
However in my code, the row is selected, and cell data all listed in text boxes where the 3 colums of data are read only. however on editing the text of the 4th column, its only the cell of the first colum that changes.
Below is part of the code that handles the editing.
private void Update_Btn_Click(object sender, EventArgs e)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
int x = 3;
DataTable dt = new DataTable();
DataGridViewRow newDataRow = dataGridView1.Rows[selectedRow];
//newDataRow.Cells[x].Value = textBoxOrd.Text;
for (int i = 0; i <= 3; i++)
{
//sb.Append("Row: ");
newDataRow.Cells[i].Value = textBoxOrd.Text;
sb.Append(dataGridView1.SelectedCells[i].RowIndex.ToString());
sb.Append(", Column: ");
sb.Append(newDataRow.Cells[i].Value.ToString());
//sb.Append(dataGridView1.SelectedCells[i].ColumnIndex.ToString());
//sb.Append(Environment.NewLine);
}
}
Attachment:
Woodstock.zip
Reply
Answers (
10
)
What is the use of threadstart class and thread class in c#.net?
How can I prevent DRY for this method?