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

  • Home
  • SEARCH
  • 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 8697739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:35:40+00:00 2026-06-13T01:35:40+00:00

I added a record in a table of SQLServer with WPF-application and refresh DataGrid

  • 0

I added a record in a table of SQLServer with WPF-application and refresh DataGrid shown a new record. For instance, I add user which has name "Peter, last name "Pen" and this record adds at the end of DataGrid. How to move focus on this record and highlight on that? In other words, how to move focus and highlight by name or surname?

ViewModel has such code:

<Window x:Class="Students.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        
        Title="MainWindow" Height="996" Width="1191" xmlns:my="clr-namespace:Students" Loaded="Window_Loaded" WindowStartupLocation="CenterScreen">    
    <Window.Resources>        
        <my: StudentDataSet x:Key="StudentDataSet" />
        <CollectionViewSource x:Key="StudentViewSource" Source="{Binding Path=S_DEP, Source={StaticResource StudentDataSet}}" />          
    </Window.Resources>

<Grid>
<DataGrid AutoGenerateColumns="False" EnableRowVirtualization="True" Height="615" HorizontalAlignment="Left" ItemsSource="{Binding Source={StaticResource StudentViewSource}}" Margin="21,322,0,0" Name="StudentDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected" VerticalAlignment="Top" Width="1046">
            <DataGrid.Columns>
                <DataGridTextColumn x:Name="NameColumn" Binding="{Binding Path=Name}" Header="Name" Width="SizeToHeader" MinWidth="110" />
                <DataGridTextColumn x:Name="LastNameColumn" Binding="{Binding Path=LastName}" Header="LastName" Width="SizeToHeader" MinWidth="100"/>                
                <DataGridTextColumn x:Name="PhoneColumn" Binding="{Binding Path=PHONE}" Header="Phone Number" Width="SizeToHeader" MinWidth="105" />               
            </DataGrid.Columns>
        </DataGrid>
</Grid>

Model has such code:

UserBoard.StudentDataSet aRCHDOC_1DataSet = ((UserBoard.StudentDataSet)(this.FindResource("StudentDataSet")));            
            // Loading data in the table Student            UserBoard.StudentDataSetTableAdapters.StudentTableAdapter StudentDataSet_StudentTableAdapter = new UserBoard.StudentDataSetTableAdapters.StudentTableAdapter();
            StudentDataSet_StudentTableAdapter.Fill(StudentDataSet.Students);
            System.Windows.Data.CollectionViewSource StudentViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("StudentViewSource")));
            StudentViewSource.View.MoveCurrentToFirst();


            //Highlighting a necessary row
            string position = e.Someth_property;
            for (int i = 0; i < StudentDataGrid.Items.Count; i++)
            {
                //What do I should write here?   
            }

Please, as a kindness to me! Give examples for WPF 2010 as code of Visual C# does not work in WPF 2010.

  • 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-13T01:35:41+00:00Added an answer on June 13, 2026 at 1:35 am

    For WPF you have to add gridview control inside Listview, after that you can easily select and focus particular record in Gridview.
    Otherwise you must have to use DataGrid Control for this kind of stuff.

    For example (Listview) refer this code:

    myListView.SelectedItem = myListView.Items[index];
    myListView.ScrollIntoView(myListView.Items[index]);
    ListViewItem listViewItem = myListView.ItemContainerGenerator.ContainerFromIndex(index) as ListViewItem;
    listViewItem.Focus(); 
    

    For example (DataGrid):

    int index = 11;
    myDataGrid.SelectedItem = myDataGrid.Items[index];
    myDataGrid.ScrollIntoView(myDataGrid.Items[index]);
    DataGridRow dgrow =(DataGridRow)myDataGrid.ItemContainerGenerator.ContainerFromItem(myDataGrid.Items[index]);
    dgrow.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have recently added a new column (age) to a database table (user). I
I have a table in database called user which has following entries. Userid FirstName
In my app, I need every new record to be added to the index
I am joining a table that has two record id fields (record1, record2) to
I want to retrieve the most recently added record from CoreData. I was wondering
I'm working on a webpage (let's call it example.com) and added the DNS record
I try to delete a record in Gridview and Database .I added a boundfield
I have a table with records which include a datetime column CreationDate. I need
I want to return the date and ID for the latest added record in
I'm using SQLServer 2008. Say I have a recursive hierarchy table, SalesRegion, whit SalesRegionId

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.