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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:48:02+00:00 2026-06-11T09:48:02+00:00

I have a grid with 5 cols and 10 rows and in each column

  • 0

I have a grid with 5 cols and 10 rows and in each column the values should be 0-9 on click on the any number I have
to get the value of the clicked cell. what is the best way to build this ?

enter image description here

  • 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-11T09:48:03+00:00Added an answer on June 11, 2026 at 9:48 am

    There are lots of ways to do this, and without knowing more about the requirements it’s hard to say which one would be best.

    One way could be to attach a mouse click listener to the Grid, and in the handler, calculate which cell was clicked.

    Grid grid = e.Source as Grid;
    Point clickedPoint = e.GetPosition(Grid.RowProperty);
    int rowClicked = (int)Math.Floor(clickedPoint.Y / grid.RowDefinitions.Count);
    

    This is good for performance as there’s only one event listener — but you’d have to make sure that any elements you place on top of the Grid allow click events to bubble up (that is, if they implement a click listener, they should use e.Handled = false).


    Another way, if you have UI elements in the Grid cells, would be to attach a click listener to each element in the Grid, and use clickedElement.GetValue(Grid.RowProperty) to get the row number.


    Edit You could create a simple 5×10 grid using code-behind like this:

            const int columns=5, rows=10;
            for (int i = 0; i < columns; i++)
            {
                grid.ColumnDefinitions.Add(new ColumnDefinition());
                for (int j = 0; j < rows; j++)
                {
                    if (i==0) grid.RowDefinitions.Add(new RowDefinition());
                    var content = new TextBlock() { Text = j.ToString() };
                    Grid.SetColumn(content, i);
                    Grid.SetRow(content, j);
                    grid.Children.Add(content);
                }
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Grid whose Rows & cols are populated dynamically. To delete a
I have a grid with multiple cols & rows. I want edit just one
I have grid of images, when the mouse is over any given image a
I have a Grid and I know the X-value and Y-Value of where I
I have grid with user data with first column having check box. I have
I have grid with several editable cols colModel: [ { name: 'id', width: 1,
I have a 10x10 grid filled with buttons, textboxes, and images, each one just
I have grid view with three column name, rate, category I am also using
I have grid like this. How to change index for each element, i.e. to
When I have Grid in Silverlight, and I provide Column Definitions like below <Grid.ColumnDefinitions>

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.