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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:54:16+00:00 2026-05-16T15:54:16+00:00

I have a combobox where the user can select a particular year (populated by

  • 0

I have a combobox where the user can select a particular year (populated by the database) and view particular information for the year. That information is stored in a datatable which is bound to a datagrid. I want it to recreate the data grid when I change the year.
_PropertyTenantData is a DataTable that has 14 columns Property Id, Property and year + Month. FillDataGrid creates the columns of _PropertyTenantData with a given year, and runs a MySQL query which fills its rows. When the selection in the ComboBox changes I want to refresh the DataGrid because it will have new column names and different data.

public ViewCurrentPropertyTenant : Window
{
    FillComboBox();
    FillDataGrid("2010");
    InitializeComponent();
}

//...

private void cboYear_SelectionChangd(object sender, SelectionChangedEventArgs e)  
{ 
    object selectedItem = cboYear.SelectedItem;
    string year = (selectedItem as YearData).Year;

    if(!String.IsNullOrEmpty(year))
    {
        _PropertyTenantData.Reset();
        FillDataGrid(year);
        myGrid.Items.Refresh();
    }
}

The first part runs fine and gives me the data as I want it structured. The second part removes all the rows, the columns stay the same, and the new rows of _PropertyTenantData are not added to the dataGrid. Thanks for the help!

  • 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-16T15:54:17+00:00Added an answer on May 16, 2026 at 3:54 pm

    Nevermind, I found the answer. Instead of refreshing I just did this:

    
    myGrid.ItemsSource = _PropertyTenantData.DefaultView;
    

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

Sidebar

Related Questions

I have a combobox and it's editable. So the user can select an item,
I have a combobox on a web form. The user can select a single
I have a combobox bound to a collection, so the user can select one
I have a user control with a combobox, and so I can edit its
I have a combobox in winforms, which, depending on what you select, determines what's
I'm creating a custom ComboBox that allows the user to select a date; the
How can you make a ComboBox where the user can select null ? If
I have a listbox that you can select users in. To the left of
I have a combobox where users can select an available language. The application contains
I have a winform containing a DropDown combobox, where the user can enter a

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.