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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:33:01+00:00 2026-05-17T22:33:01+00:00

I have a wpf datagrid with 2 columns (ProductID and Description). ProductID column is

  • 0

I have a wpf datagrid with 2 columns (ProductID and Description). ProductID column is a combobox and the Description is a Textbox. On the SelectionChanged event of the ProductID, I want to assign a value to the Description column. I need to know how to assign the value to the Description textbox for the row of the combobox that fired the SelectionChanged event. Can someone please provide a sample code? This seems so simple but I can’t find an answer. Thanks

  • 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-05-17T22:33:01+00:00Added an answer on May 17, 2026 at 10:33 pm

    A better way to do this is by using Binding to Properties like

    private ProductIdEnum m_productId;
    public ProductIdEnum ProductId
    {
        get
        {
            return m_productId;
        }
        set
        {
            m_productId = value;
            // Value changed...
        }
    }
    

    To add an EventHandler for the SelectionChanged event of the ComboBox you could do this but I wouldn’t recommend it.

    <DataGridComboBoxColumn Header="ProductID"
                            ...">
        <DataGridComboBoxColumn.EditingElementStyle>
            <Style TargetType="{x:Type ComboBox}">
                <EventSetter Event="SelectionChanged" Handler="ProductIdChanged" />
            </Style>
        </DataGridComboBoxColumn.EditingElementStyle>
    </DataGridComboBoxColumn>
    

    And in code behind

    public T GetVisualParent<T>(object childObject) where T : Visual
    {
        DependencyObject child = childObject as DependencyObject;
        while ((child != null) && !(child is T))
        {
            child = VisualTreeHelper.GetParent(child);
        }
        return child as T;
    }
    
    void ProductIdChanged(object sender, SelectionChangedEventArgs e)
    {
        ComboBox comboBox = sender as ComboBox;
        DataGridRow dataGridRow = GetVisualParent<DataGridRow>(comboBox);
        SomeClass myClass = dataGridRow.Item as SomeClass;
        // Set description
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DataGrid in WPF app with several columns, including a Name column.
I have wpf datagrid with number of template columns. some of them have textbox
I have this columns in datagrid wpf <DataGrid.Columns> <DataGridComboBoxColumn SelectedItemBinding={Binding Path=ProductId} DisplayMemberPath=Name SelectedValuePath=Id />
I want to achieve the following: Create a WPF DataGrid that have 2 columns:
I have a WPF Datagrid with a Text Column, two Template Columns, and two
I have a WPF toolkit DataGrid as the dropdown in a ComboBox template. <toolkit:DataGrid
I have a WPF DataGrid where a column, actually a DataGridComboBoxColumn, is bound to
I have a WPF DataGrid that I want to be able to Update, Insert
I have a WPF DataGrid (.NET 4) with custom template columns and header styles
I have a WPF Datagrid and its integer datatype columns are editable and hence

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.