Data Grid help

  • Thread starter Thread starter Shane
  • Start date Start date
S

Shane

I made a Database in MS Access, and i want to try to port
it over to VB.NET. One thing i have is a subform that is a
datasheet. what I want to know, is there away to make the
data grid to have combo boxes or is there away edit the
data grid some how?


Shane
 
Dear Shane,

..Net DataGrid basically contains a collection of type
GridTableStylesCollection accessible through the
TableStyles property of the DataGrid.

Each tablestyle (of type DataGridTableStyle) within this
collection corresponds to a DataTable. This mapping is
done by setting the MappingName property of the
DataGridTableStyle object to the name of the DataTable.

Finally each TableStyle (type DataGridTableStyle)
contains a property GridColumnStyles that returns a
collection of type GridColumnStylesCollection. This
collection contains individual instances of types derived
from DataGridColumnStyle. The existing types that this
collection can hold are DataGridTextboxColumn and
DataGridBoolColumn for displaying the textbox style of
column or checkbox style of columns respectively.


For displaying combobox, you will have to create a class,
say DataGridComboboxColumn that should derive from the
DataGridColumnStyle class. Within this class
implementation you can write your code to display the
combobox. Try it out.... In case you require more help, I
can send you the implemented code for this class.

Finally instead of having DataGridTextboxColumn or
DataGridBoolColumn instances added to the
GridColumnStylesCollection class, you will have to ensure
that the DataGridComboboxColumn instance is added to your
generated form's code. Remember each type within the
GridColumnStylesCollection class corresponds to a
DataColumn. This mapping is done using the MappingName
property of the DataGridColumnStyle class (accessible
through one of the derived types). Basically the
MappingName property is set the same string as ColumnName.


Regards,
Puneet Taneja
 
Back
Top