Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7890081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:15:42+00:00 2026-06-03T06:15:42+00:00

I’ve found several topics with a similar issue but the contents seemed slightly different

  • 0

I’ve found several topics with a similar issue but the contents seemed slightly different and I have not been able to solve my problem as a result.

In my application I have DataTable that contains 4 columns:

  • UInt16
  • UInt64
  • UInt64
  • A self defined enumeration type consisting of 2 values.

In order to display the values of this DataTable I created a DataGridView and set this table as the datasource. So far so good. I wanted the enumeration field column to contain comboboxes instead and ran into the DataGridViewComboBoxColumn type. I had some issues getting it to work but eventualy ended up using the following approach:

// Create the 4 datarows

// Add the datarows to the data table

// Set the data table as the data source for the data grid view

// Remove the column that represents the enumeration

// Add a DataGridViewComboBoxColumn to the DataGridView as replacement

I have created the DataGridViewComboBoxColumn as follows:

DataGridViewComboBoxColumn cb = new DataGridViewComboBoxColumn();
cb.HeaderText   = "My header text";
cb.ValueType    = typeof(MyEnumType);
cb.DataSource   = Enum.GetValues(typeof(MyEnumType));
cb.FlatStyle    = FlatStyle.System;
cb.Name         = "Name"; //Same name as the DataColumn and the now deleted DataGridViewColumn
cb.DataPropertyName = "Name"; //Same name as the DataColumn and the now deleted DataGridViewColumn
cb.DisplayStyle     = DataGridViewComboBoxDisplayStyle.Nothing;

dataGridView.Columns.Add(cb);

Once my application starts I read in data from a text file that get placed into a structure with fields of the 4 datatypes mentioned above. I then add these fields to the DataTable as follows:

DataRow row = dataTable.NewRow();
row["Name of the UInt16 column"]    = mystruct.theUInt16;
row["Name of the UInt64 column"]    = mystruct.theUInt64;
row["Name of the UInt64 column"]    = mystruct.theUInt64_2;
row["Name of the enum column"]      = mystruct.theEnumValue;               
dataTable.Rows.Add(row);

on startup the DataError event gets called repeatedly. The contents of the cells do get filled properly however. (I see this after clicking away the error a couple of times) Disabling the DataError event (assigning an empty handler for example) is something I prefer to not do.

I think there is some sort of type mismatch somehow. (maybe the enum type and a string for display?) This is however only a guess. The dataTable column and the datagridview column both have the type set to the enumeration.

I hope someone can point me in the right direction.

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T06:15:43+00:00Added an answer on June 3, 2026 at 6:15 am

    I have managed to find a workaround that suits my needs. The approach is still the same as in my original post. I made gave the enum in the DataTable the name “colMyEnumTypeTable” and the datatype is string instead of MyEnumType. Then I removed this column and added the DataGridViewComboBoxColumn named “colMyEnumType” with DataPropertyName “colMyEnumTypeTable” and also being of type string. I then convert the enumeration values to string when adding them to the data table, and when extracting I use Enum.Parse to retrieve the enum value again. No more DataError calls are made.

    -edit-
    I gave the DataTable and DataGridViewComboBoxColumn different names to ensure that wasn’t causing problems. I have now changed them back so they have the same name and it still works.

    -edit2-
    And instead of setting the DataSource property for the comboboxcolumn I added the enum values by adding them to the Items property. (after converted to string)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
This could be a duplicate question, but I have no idea what search terms
I have been unable to fix a problem with Java Unicode and encoding. The
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.