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 8986633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:35:46+00:00 2026-06-15T21:35:46+00:00

I just cant get this to work. I have a datagridview in winforms and

  • 0

I just cant get this to work.
I have a datagridview in winforms and in this one of my columns is a DataGridViewComboBoxColumn.

In my constructor I set it up like so

DataGridViewComboBoxColumn column = (DataGridViewComboBoxColumn)RectangleGrid.Columns["Material"];

        DataTable data = new DataTable();

        data.Columns.Add(new DataColumn("Value", typeof(int)));
        data.Columns.Add(new DataColumn("Description", typeof(string)));

        foreach (Materials M in DataStructure.Active.Active_Materials)
        {
            data.Rows.Add(M.MaterialNr, (M.MaterialNr + 1).ToString() + " " + M.Material.Name);
        }

        column.DataSource = data;
        column.ValueMember = "Value";
        column.DisplayMember = "Description";

And it actually works well except that nothing is selected in the drop down box which I want. I have googled this and for instance tried this approach: http://goo.gl/kBy8W but with no go because EditingControlShowing only happens when i click the box and not when it first comes up (so I can set selected index once it’s clicked but thats no good).
The CellFormatting version at least changes the value but it just puts a string there rather than my first index from my data source.

I also tried this

column.DefaultCellStyle.NullValue = data.Rows[0]["Description"];
column.DefaultCellStyle.DataSourceNullValue = data.Rows[0]["Value"];

and that seemed to work but then when i selected the first index in the dropdown (so drop the dropdown down and then select the first index and then deselct the cell) I got an error from ParseFormattedValue where it says it cannot convert “value” to system.String.

There was this which seemed to be on the right track but i could not get it to work: http://goo.gl/VevA3

  • 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-15T21:35:47+00:00Added an answer on June 15, 2026 at 9:35 pm

    I ended up “solving” it in a very dirty solution that I don’t like but it sort of works.

    I had my datagridview bound to a datatable (not database) so what i did was i connected an event handler to the TableNewRow event in the datatable.

    then i did this in that event handler

        private void NewRectangleInserted(Object sender, DataTableNewRowEventArgs e)
        {
            if (e.Row[0].ToString() == "")
            {
                e.Row[0] = 0;
            }
        }
    

    So basically when a new row is created I set the value of the combobox to 0 unless the user created the row by adding a value in that particular cell (why i check if it equals “”)

    The result is that as soon as you highlight a new line or any cell in a line the combobox is filled in. however the new line at the botton still has a blank combobox until you highlight it.

    not perfect but a lot better. to bad it had to be done with a hack!

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

Sidebar

Related Questions

I have tried everything to get this to work and just cant get the
I have literally just started programing with Ajax and cant get this to work.
I just cant get this to work... I have the following routes: routes.IgnoreRoute({resource}.axd/{*pathInfo}); routes.IgnoreRoute(*.html|js|css|gif|jpg|jpeg|png|swf);
This should be a really simple one, but just cant get it to work.
I can't get this code to work. Declared playpauseButton just above the given below
I'm using this animation to animate a LinearLayout, but I just cant get it
well i have this trouble and ive been dealing with but i just cant
i cant work out how to get this subquery working to get the latest
I think this is a simple problem, but i just cant get my head
I've searched everywhere and cant get this to work at all... Nginx 1.0.11, php

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.