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;

 

 

Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *