Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. ComboBox in DataGrid, shows up but won't drop down when clicked.

ComboBox in DataGrid, shows up but won't drop down when clicked.

Scheduled Pinned Locked Moved C#
csharpcomhelptutorial
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    krisp
    wrote on last edited by
    #1

    I used Microsoft's way of adding a combobox to a datagrid by just adding a combobox to the datagrid's controls and moving it to the proper row and column when CurrentCellChanged is fired. http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q323167 This code they give is in VB.Net, and I assume it works because many people have used it (from reading on forums). However, when I converted it to C# it does not drop down when it is clicked. I do add it to the DataGrid.Controls and it is displayed. I do not think i should have to add events for clicking, the combo box is in the datagrid's controls and should receive the click event itself and drop down. If it works in VB.Net I can't see why it would be any different in C#. Has anyone ever done their example in C# and got it to work, I know I can make my own DataGridColumnStyle and i have found examples of it that work. But I really like the simplicity of Microsoft's way and the fact that I should be able to just add any control to the datagrid. Thanks for any help. DataColumn editJobNameColumn = new DataColumn( "Job Name", typeof( string ) ); editJobNameColumn.AllowDBNull = false; editJobNameColumn.Unique = true; editJobNameColumn.DefaultValue = ""; DataColumn editJobRateColumn = new DataColumn( "Charge Rate", typeof( decimal ) ); editJobRateColumn.AllowDBNull = false; editJobRateColumn.DefaultValue = 0.0M; DataTable editJobsRates = new DataTable( "Jobs" ); editJobsRates.Columns.Add( editJobNameColumn ); editJobsRates.Columns.Add( editJobRateColumn ); dtvwEditJobs.Table = editJobsRates; this.dtgdEditJobs.DataSource = this.dtvwEditJobs; this.dtgdEditJobs.Click += new System.EventHandler(this.dtgdEditJobs_Click); this.dtgdEditJobs.CurrentCellChanged += new System.EventHandler(this.dtgdEditJobs_CurrentCellChanged); this.dtgdEditJobs.Paint += new System.Windows.Forms.PaintEventHandler(this.dtgdEditJobs_Paint); this.dtgdEditJobs.Scroll += new System.EventHandler(this.dtgdEditJobs_Scroll); private void dtgdEditJobs_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { if( dtgdEditJobs.CurrentCell.ColumnNumber == 0 ) { cmbEditJobs.Width = dtgdEditJobs.GetCurrentCellBounds().Width; } } private void dtgdEditJobs_Click(object sender, System.EventArgs e) { cmbEditJobs.Visible = false; cmbEditJobs.Width = 0; } private void dtgdEditJobs_Scroll(object sender, System.EventArgs e) { cmbEditJobs.Visible = false; cmbEditJobs.Width = 0; } private void dtgdEditJobs_CurrentCellChanged(object

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups