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
S M Fasih ALi
NA
37
1.6k
Edit selected item of datagridview and .txt file as well
Apr 12 2016 2:30 PM
Hi, friends i want to edit contact in my phone directory application using datagrid, textbox and a button
please help me !!
and my second question is about deleting I had completed deleting process but some time it doesn't work correctly!
!!here is the code!!
private void button2_Click(object sender, EventArgs e)
{
List<string> myList = File.ReadAllLines("contact.txt").ToList(); //read
foreach (DataGridViewRow item in this.dataGridView1.SelectedRows)
{
try
{
DialogResult result = MessageBox.Show("are you sure to delete!!", "Warning!!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
myList.RemoveAt(item.Index);
File.WriteAllLines("contact.txt", myList.ToArray());
dataGridView1.Rows.RemoveAt(item.Index);
}
else
{
this.dataGridView1.Focus();
}
}
catch
{
MessageBox.Show("unable to delete", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
Reply
Answers (
1
)
tutorial- question about events- expression "value"
Sql Server Update problem