Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Adding a ComboBox to a DataGrid
Message
 
À
07/01/2004 15:24:43
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00863988
Message ID:
00864878
Vues:
18
Hi Terry!

We're finally making progress!!!
I did as you said and I now have a DataGrid with a ComboBox!
It's not tied in the way I want it, but it's there!
(can you tell I'm happy and excited?)

The Northwind.Orders.ShipVia is a numeric field and it referrs to
the Northwind.Shippers.CompanyName field
When I set the ComboBox to String content, and edited the record, the system complains that the data type is wrong... of course, I'd be more concerned if it didn't complain.

I assume the next step is to adjust my dataset to contain the String content as well, and then adjust the value saved via code?

Rick

______________________
>Hi Rick,
>
>The next step is to get the code from the Syncfusion sample into your app. This type of code is a perfect candidate to put in a base class assembly but we will take the simple route and just add it to your project.
>
>In your project add two new class file to your project one named “DataGridComboBoxColumn” and the other “NoKeyUpCombo”. Delete all the default code generated in the new class files. Copy the code from the Syncfusion app to the respective files into your app.
>
>Remove the lines of code referencing the Namespace… also the last line End Namespace from both classes. This will cause the code to be included in your app default Namespace.
>
>Save and close the files. You might recompile to check for any error to this point.
>
>Now go to the method where you setup the table style and add the column style for you combobox. In this example col4 is add to the previous code after the col3 definition and before the lines;
>
>Me.grdNameOfGrid.TableStyles.Clear()
>Me.grdNameOfGrid.TableStyles.Add(tsTableStyle)
>
>
>Hope this gets you going,
>
>
>Terry Carroll
>
>
>
   ' Init the DataGridComboBoxColumn you added to your project
>        Dim Col4 As New DataGridComboBoxColumn
>
>        ' Do some house cleaning. Set the Grid row height a little higher than the combobox
>        Me.grdNameOfGrid.PreferredRowHeight = Col4.ColumnComboBox.Height + 2
>
>
>        ' Load data into the combobox using a dataset returned from a call to a business object
>        ' You could define the dataset for the combobox in the form designer in which case
>        ' the next two lines of code would not be included.
>        Dim dsMailTypes As DataSet
>        dsMailTypes = Me.oNtoBusiness.GetMailTypes()
>
>        'Once you have a dataset with a table to bind to the combobox you set the following properties.
>        'dsMailTypes is the name of your dataset and in this example "ProjInfo" is the
>        ' name of the data table. Alternatively, you could define the combobox elements in code
>        Col4.ColumnComboBox.DataSource = dsMailTypes.Tables("ProjInfo").DefaultView
>        Col4.ColumnComboBox.DisplayMember = "PiLabel"    ' column name to display
>        Col4.ColumnComboBox.ValueMember = "PiShortKey"    ' column name to bind to data
>
>
>        ' Set the rest of the properties for the column style
>        Col4.MappingName = "m_mailtype"
>        Col4.HeaderText = "Type"
>        Col4.Width = 80
>        Col4.Format = ""
>        Col4.FormatInfo = Nothing
>        ' Add the column to the tablestyle
>        tsTableStyle.GridColumnStyles.Add(Col4)
>
>
>
>
>>I've got the DataGrid showing the fields I want and formating a couple of them...Elsewhere I've got Comboboxes working...
>>What's the next step in getting the ComboBox into the DataGrid?
>>
>>Rick
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform