If you only want the sorting to happen when the value of the drugsDataGridViewTextBoxColumn changes, alter your code something like this:
private void dgDrugs_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
try
{
if (dgDrugs.Rows.Count > 0)
{
#region Sorting Feature
if (e.ColumnIndex == this.dataGridView1.Columns["drugsDataGridViewTextBoxColumn"].Index)
{
this.dataGridView1.Sort(this.dataGridView1.Columns[e.ColumnIndex], ListSortDirection.Ascending);
}
#endregion
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
I have commented out your unsubscribing from the event and then subscribing again lines because I have just tried this and it works fine on my system.
If you get problems, my tests suggest that they are not caused by this code.
Of course, I could be wrong. :)