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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:21:32+00:00 2026-06-15T23:21:32+00:00

I am new in WPF. I used to work in Winforms. In Winforms I

  • 0

I am new in WPF. I used to work in Winforms.

In Winforms I had the DataGridView that allows me to change, when I want a cell value.

Simply using:

dataGridView[columnIndex, rowIndex].Value = "New Value";

It works.

How can I accomplish this using DataGrid from WPF?
I was looking thorught stack over flow and could figure out an easy way to do this.

Thank you

  • 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-06-15T23:21:34+00:00Added an answer on June 15, 2026 at 11:21 pm

    Ok the simplest way to handle DataGrid is by binding to an ItemSource.

    The example below shows how to bind your list and how changes upadte the DataGrid.

    public partial class MainWindow : Window
    {
        private ObservableCollection<ConnectionItem> _connectionitems = new ObservableCollection<ConnectionItem>();
    
        public MainWindow()
        {
            InitializeComponent();
            ConnectionItems.Add(new ConnectionItem { Name = "Item1", Ping = "150ms" });
            ConnectionItems.Add(new ConnectionItem { Name = "Item2", Ping = "122ms" });
        }
    
        public ObservableCollection<ConnectionItem> ConnectionItems
        {
            get { return _connectionitems; }
            set { _connectionitems = value; }
        }
    
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            // to change a value jus find the item you want in the list and change it
            // because your ConnectionItem class implements INotifyPropertyChanged
            // ite will automaticly update the dataGrid
    
            // Example
            ConnectionItems[0].Ping = "new ping :)";
        }
    }
    
    public class ConnectionItem : INotifyPropertyChanged
    {
        private string _name;
        private string _ping;
    
        public string Name
        {
            get { return _name; }
            set { _name = value; NotifyPropertyChanged("Name"); }
        }
    
        public string Ping
        {
            get { return _ping; }
            set { _ping = value; NotifyPropertyChanged("Ping"); }
        }
    
        public event PropertyChangedEventHandler PropertyChanged;
        /// <summary>
        /// Notifies the property changed.
        /// </summary>
        /// <param name="property">The info.</param>
        public void NotifyPropertyChanged(string property)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(property));
            }
        }
    }
    

    Xaml:

    <Window x:Class="WpfApplication4.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:local="clr-namespace:WpfApplication4"
            xmlns:properties="clr-namespace:WpfApplication4.Properties"
            Title="MainWindow" Height="300" Width="400" Name="UI" >
        <Grid>
            <DataGrid Name="dataGridView" ItemsSource="{Binding ElementName=UI,Path=ConnectionItems}" Margin="0,0,0,40" />
            <Button Content="Change" Height="23" HorizontalAlignment="Left" Margin="5,0,0,12" Name="button1" VerticalAlignment="Bottom" Width="75" Click="button1_Click" />
        </Grid>
    </Window>
    

    i added a button to show how the data updates when you change something in your list, The class ConnectionItem is where you will store all your info for the datagrid.

    Hope this helps

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

Sidebar

Related Questions

being new to WPF this is a complex problem for me. What i want
I'm pretty new to WPF and using the MVVM design pattern. To help learn
I am new to WPF. I have a ListBox that has its ItemSource set
I'm creating a new project that is following closely to the design used by
I'm very new in WPF. I've got a ListBox where I want to set
I haven't used WPF that much so the solution to this is probably pretty
note I am new in Wpf > I have project that decode qr code
I'm new to WPF and I haven't used MVVM yet but I think I'm
In WPF I often used such a construction: SomeChildWindow dlg = new SomeChildWindow(); dlg.ShowDialog();
When I create a new WPF application in Visual Studio 2012 the platform target

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.