/* ------------------------ My Meta Content Here SEO ------------------------ */

Pages

Main Menu

Friday, April 15, 2011

VB.NET Sorting in Data Grid View

For Each c In Me.DataGridView1.Columns

c.SortMode = DataGridViewColumnSortMode.NotSortable

Next

This is the DataGridView handler you need to capture the button click event.

this.dgvList.CellContentClick += new DataGridViewCellEventHandler(DGV_CellContentClick);

This is the button click handler example

#region DGV_CellContentClick

public void DGV_CellContentClick(object sender, DataGridViewCellEventArgs e)

{

int selectedRowIndex = int.Parse(e.RowIndex.ToString());



if (this.dgvList.Columns[e.ColumnIndex] == buttonColumn && selectedRowIndex >= 0)

{

DataRow dr = DataGridViewHelper.GetDataRow(this.dgvList);

MessageBox.Show((string)dr["FirstName"]);

}

}

No comments:

Post a Comment

My Blog List

  • काश - काश मुझे भी पीने की आदत होती,मैं कब का मुर्दा हो गया होता। छुटकारा मिलता आज के आतंकवाद से, किसी संतान भूमि में सो गया होता। मेरा एतबार कौन करेगा, मैंने मुर...
    3 months ago
  • काश - काश मुझे भी पीने की आदत होती,मैं कब का मुर्दा हो गया होता। छुटकारा मिलता आज के आतंकवाद से, किसी शमशान भूमि में सो गया होता। मेरा एतबार कौन करेगा, मैंने मुर...
    3 months ago
  • Kumaon University Nainital B.Ed entrance exam test result 2012 - कुमाऊँ विश्वविधालय, नैनीताल (उत्तराखण्ड)
    10 years ago