Alterntaives to Data Grid View

The List View control provides several of the data grid view features including multiple columns per item.

If you want to use images in columns other than column 1 or buttons then a datagrid view is usually a better choice.

Column Types

DataGridView columns can setup as:

Text
Button
CheckBox
ComboBox
Image
Link

Each cell in a column has to have the same type, but they can be customised with different button text, etc.

Clear Data Grid


dgvEdidBlock->DataSource = nullptr;

Clear All Columns


	dataGridView1->Columns->Clear();

1 Click To Edit Checkboxes, Combo Box values, etc

Change the EditMode property of your DataGridView control to "EditOnEnter".

Read Data Grid Value


TxBuffer += String::Format("{0:X2}", MyDataGridView1->Rows[Count]->Cells[2]->Value->ToString());

Looping through rows and cells


	for each(DataGridViewRow ^NextRow in dataGridView1->Rows)
	{
		for each(DataGridViewCell ^NextCell in NextRow->Cells)
		{
						
		}
	}

Disable click column header to sort by column


	for each (DataGridViewColumn ^DataGridViewColumn1 in dataGridView1->Columns)
		DataGridViewColumn1->SortMode = DataGridViewColumnSortMode::NotSortable;

 

 

USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.