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. Windows Forms
  4. Reading from Comboboxes on a datagrid view (C++/CLI - Windows Forms App in VS2008) [modified]

Reading from Comboboxes on a datagrid view (C++/CLI - Windows Forms App in VS2008) [modified]

Scheduled Pinned Locked Moved Windows Forms
c++cssdatabasewinformsgraphics
4 Posts 3 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.
  • G Offline
    G Offline
    Ger Hayden
    wrote on last edited by
    #1

    I have my filtered combo boxes working in a datagridview thanks to a Linda Liu sample. Now when I enter a row I want to see the data from a row in a sequence of text boxes below the grid - but for the combo boxes I only see the index, when I would prefer to see the information e.g. route description. Here is a cutdown version of From1.h:

    namespace DataGridViewComboEx5 {

    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Collections::Generic;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;
    using namespace System::IO;
    
    public ref class Form1 : public System::Windows::Forms::Form
    {
    public:
    	Form1(void)
    	{
    		InitializeComponent();
    		//
    		//TODO: Add the constructor code here
    		//
    	}
    
    protected:
    	/// <summary>
    	/// Clean up any resources being used.
    	/// </summary>
    	~Form1()
    	{
    		if (components)
    		{
    			delete components;
    		}
    	}
    private: System::Windows::Forms::DataGridView^  gridPassenger;
    private: System::Windows::Forms::DataGridViewComboBoxColumn^  dgRoute;
    private: System::Windows::Forms::DataGridViewComboBoxColumn^  dgStage;
    private: System::Windows::Forms::DataGridViewTextBoxColumn^  dgPerson;
    private: System::Windows::Forms::Label^  label1;
    private: System::Windows::Forms::Label^  lblPerson;
    private: System::Windows::Forms::Label^  lblStage;
    private: System::Windows::Forms::Label^  label3;
    private: System::Windows::Forms::Label^  lblRoute;
    private: System::Windows::Forms::Label^  label5;
    

    :
    :

    ref class ViewPassengerData
    {
    private:
    int m_Route;
    int m_Stage;
    String ^m_Person;
    public:
    ViewPassengerData(int Route, int Stage, String^ Person)
    {
    m_Route = Route;
    m_Stage = Stage;
    m_Person = gcnew String(Person);
    }
    property int RouteID
    {
    int get()
    {
    return m_Route;
    }
    void set(int value)
    {
    m_Route = value;
    }
    }
    property int StageID
    {
    int get()
    {
    return m_Stage;
    }
    void set(int value)
    {
    m_Stage = value;
    }
    }
    property String^ Person
    {
    String^ get()
    {
    return m_Person;
    }
    void set(String^ value)
    {
    m_Person = value;
    }
    }
    };
    private:
    List<ViewPassengerData^> ^m_DataList;
    DataSet ^RouteStages;
    DataTable ^dtRoute;
    DataTable ^dtStages;
    BindingSource ^bsRoute;
    BindingSource ^childBS;
    BindingSource ^filteredStages;
    bool m_LoadComplete;

    private: System:

    D 1 Reply Last reply
    0
    • G Ger Hayden

      I have my filtered combo boxes working in a datagridview thanks to a Linda Liu sample. Now when I enter a row I want to see the data from a row in a sequence of text boxes below the grid - but for the combo boxes I only see the index, when I would prefer to see the information e.g. route description. Here is a cutdown version of From1.h:

      namespace DataGridViewComboEx5 {

      using namespace System;
      using namespace System::ComponentModel;
      using namespace System::Collections;
      using namespace System::Collections::Generic;
      using namespace System::Windows::Forms;
      using namespace System::Data;
      using namespace System::Drawing;
      using namespace System::IO;
      
      public ref class Form1 : public System::Windows::Forms::Form
      {
      public:
      	Form1(void)
      	{
      		InitializeComponent();
      		//
      		//TODO: Add the constructor code here
      		//
      	}
      
      protected:
      	/// <summary>
      	/// Clean up any resources being used.
      	/// </summary>
      	~Form1()
      	{
      		if (components)
      		{
      			delete components;
      		}
      	}
      private: System::Windows::Forms::DataGridView^  gridPassenger;
      private: System::Windows::Forms::DataGridViewComboBoxColumn^  dgRoute;
      private: System::Windows::Forms::DataGridViewComboBoxColumn^  dgStage;
      private: System::Windows::Forms::DataGridViewTextBoxColumn^  dgPerson;
      private: System::Windows::Forms::Label^  label1;
      private: System::Windows::Forms::Label^  lblPerson;
      private: System::Windows::Forms::Label^  lblStage;
      private: System::Windows::Forms::Label^  label3;
      private: System::Windows::Forms::Label^  lblRoute;
      private: System::Windows::Forms::Label^  label5;
      

      :
      :

      ref class ViewPassengerData
      {
      private:
      int m_Route;
      int m_Stage;
      String ^m_Person;
      public:
      ViewPassengerData(int Route, int Stage, String^ Person)
      {
      m_Route = Route;
      m_Stage = Stage;
      m_Person = gcnew String(Person);
      }
      property int RouteID
      {
      int get()
      {
      return m_Route;
      }
      void set(int value)
      {
      m_Route = value;
      }
      }
      property int StageID
      {
      int get()
      {
      return m_Stage;
      }
      void set(int value)
      {
      m_Stage = value;
      }
      }
      property String^ Person
      {
      String^ get()
      {
      return m_Person;
      }
      void set(String^ value)
      {
      m_Person = value;
      }
      }
      };
      private:
      List<ViewPassengerData^> ^m_DataList;
      DataSet ^RouteStages;
      DataTable ^dtRoute;
      DataTable ^dtStages;
      BindingSource ^bsRoute;
      BindingSource ^childBS;
      BindingSource ^filteredStages;
      bool m_LoadComplete;

      private: System:

      D Offline
      D Offline
      DJ Matthews
      wrote on last edited by
      #2

      When you have code like this, please wrap the block of code in a <pre> </pre> tags. It makes it easier to read.

      G 1 Reply Last reply
      0
      • D DJ Matthews

        When you have code like this, please wrap the block of code in a <pre> </pre> tags. It makes it easier to read.

        G Offline
        G Offline
        Ger Hayden
        wrote on last edited by
        #3

        Done - wasn't aware of them - and I've chopped out much of the autogenerated code. Ger

        Ger

        L 1 Reply Last reply
        0
        • G Ger Hayden

          Done - wasn't aware of them - and I've chopped out much of the autogenerated code. Ger

          Ger

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Ger Hayden wrote:

          wasn't aware of them

          See point 7 in the Forum Guidelines[^].

          Just say 'NO' to evaluated arguments for diadic functions! Ash

          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