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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. New Combobox Challenge!

New Combobox Challenge!

Scheduled Pinned Locked Moved C#
databasehelp
1 Posts 1 Posters 1 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.
  • S Offline
    S Offline
    SpeBeeTo
    wrote on last edited by
    #1

    I have another problem, errr, challenge now. I am using an SQL database to save the info the person chooses on one form (pedbone.cs). Here's the code to the Combobox I've got on the "main" form (pedbone.cs): // populate the list - gender m_cTypes = new ArrayList(); m_cTypes.Add("Unknown"); m_cTypes.Add("Male"); m_cTypes.Add("Female"); TypeCombo.DataSource = m_cTypes; These are listed in a ListView SqlCeCommand sqlLoadEvents = m_cConn.CreateCommand(); sqlLoadEvents.CommandText = szSQL; SqlCeDataReader rReader = sqlLoadEvents.ExecuteReader(); while ( rReader.Read() ) { lvItem.SubItems.Add(GetTypeFromNumber ((int)rReader.GetValue(rReader.GetOrdinal("MovieType"))));// Gender CollectionList.Items.Add( lvItem ); } } And here I got the Combobox text to show in the ListView, by using this code private string GetTypeFromNumber(int nTypeID) { return (m_cTypes[nTypeID].ToString()); } Now, when you click on the listview item, a new form opens up (AddEditMovieForm.cs) to view the file in more detail. And here's where I'm running into a bit of a bind. public AddEditMovieForm(SqlCeConnection cConn, int nMovieID) { InitializeComponent(); m_cConn = cConn; m_nMovieID = nMovieID; m_cTypes = new ArrayList(); if ( m_nMovieID != -1 ) { SqlCeCommand sqlCommand = m_cConn.CreateCommand(); sqlCommand.CommandText = "SELECT * FROM MOVIE_MNGR_TABLE where MovieID = "+m_nMovieID.ToString(); SqlCeDataReader rReader = sqlCommand.ExecuteReader(); if ( rReader.Read() ) { } { GenderLabel.Text = rReader.GetValue(rReader.GetOrdinal("MovieType")).ToString();// Gender { } } } } Any help would be appreciated. I would like to add "male" or "female" into the GenderLabel.Text field. If I neglected to add any important code, please let me know. Thanks guys, M.

    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