Hi PRA,
I have created sample code which full-fill your requirement.
C#
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.GetData();
}
private void GetData()
{
DataTable dt = new DataTable();
dt.Columns.Add("EmpId");
dt.Columns.Add("EmpName");
dt.Columns.Add("Insurance");
dt.Rows.Add("1", "Rustam", "");
dt.Rows.Add("2", "Suhrob", "");
dt.Rows.Add("3", "Firuz", "");
dataGridView1.AutoGenerateColumns = false;
dataGridView1.ColumnCount = 3;
dataGridView1.Columns[0].Name = "EmpId";
dataGridView1.Columns[0].HeaderText = "EmpId";
dataGridView1.Columns[0].DataPropertyName = "EmpId";
dataGridView1.Columns[1].HeaderText = "EmpName";
dataGridView1.Columns[1].Name = "EmpName";
dataGridView1.Columns[1].DataPropertyName = "EmpName";
dataGridView1.Columns[2].Name = "Insurance";
dataGridView1.Columns[2].HeaderText = "Insurance";
dataGridView1.Columns[2].DataPropertyName = "Insurance";
dataGridView1.DataSource = dt;
}
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
string salary = dataGridView1.CurrentRow.Cells[2].Value.ToString();
dataGridView1.CurrentRow.Cells[2].Value = Convert.ToDouble(salary) * 0.01;
}
}
Vb.Net
Public Partial Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
Me.GetData()
End Sub
Private Sub GetData()
Dim dt As New DataTable()
dt.Columns.Add("EmpId")
dt.Columns.Add("EmpName")
dt.Columns.Add("Insurance")
dt.Rows.Add("1", "Rustam", "")
dt.Rows.Add("2", "Suhrob", "")
dt.Rows.Add("3", "Firuz", "")
dataGridView1.AutoGenerateColumns = False
dataGridView1.ColumnCount = 3
dataGridView1.Columns(0).Name = "EmpId"
dataGridView1.Columns(0).HeaderText = "EmpId"
dataGridView1.Columns(0).DataPropertyName = "EmpId"
dataGridView1.Columns(1).HeaderText = "EmpName"
dataGridView1.Columns(1).Name = "EmpName"
dataGridView1.Columns(1).DataPropertyName = "EmpName"
dataGridView1.Columns(2).Name = "Insurance"
dataGridView1.Columns(2).HeaderText = "Insurance"
dataGridView1.Columns(2).DataPropertyName = "Insurance"
dataGridView1.DataSource = dt
End Sub
Private Sub dataGridView1_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs)
Dim salary As String = dataGridView1.CurrentRow.Cells(2).Value.ToString()
dataGridView1.CurrentRow.Cells(2).Value = Convert.ToDouble(salary) * 0.01
End Sub
End Class
Screenshot