예제 #1
0
        /// <summary>
        /// Displays selected sells coordinates on status bar
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="selectedCellsChangedEventArgs"></param>
        private void CoordinatesOfSelectedCells_OnSelectedCellsChanged(object sender, SelectedCellsChangedEventArgs selectedCellsChangedEventArgs)
        {
            try
            {
                var dataGrid = (ExtendedDataGrid)sender;

                StringBuilder selectedCellsCoordinates = new StringBuilder();
                selectedCellsCoordinates.Append("Selected cells: ");

                foreach (var cellInfo in dataGrid.SelectedCells)
                {
                    // this changes the cell's content not the data item behind it
                    var gridCell = dataGrid.TryToFindGridCell(cellInfo);
                    if (gridCell != null)
                    {
                        string columnHeader = gridCell.Column.Header.ToString();
                        int rowIndex = dataGrid.Items.IndexOf(cellInfo.Item);

                        selectedCellsCoordinates.Append(string.Format("[{0},{1}] ", columnHeader, rowIndex));
                    }
                }

                this.DisplayAdditionalInfo(dataGrid);

                StatusBarTextBox.Text = selectedCellsCoordinates.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.GetType().Name + ": " + ex.Message, "Error occured during selecting cells", MessageBoxButton.OK, MessageBoxImage.Error);
                Logger.WriteLogException(ex.GetType().Name + ": " + ex.Message);
            }
        }
예제 #2
0
        /// <summary>
        /// Displays selected sells coordinates on status bar
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="selectedCellsChangedEventArgs"></param>
        private void CoordinatesOfSelectedCells_OnSelectedCellsChanged(object sender, SelectedCellsChangedEventArgs selectedCellsChangedEventArgs)
        {
            try
            {
                var dataGrid = (ExtendedDataGrid)sender;

                StringBuilder selectedCellsCoordinates = new StringBuilder();
                selectedCellsCoordinates.Append("Selected cells: ");

                foreach (var cellInfo in dataGrid.SelectedCells)
                {
                    // this changes the cell's content not the data item behind it
                    var gridCell = dataGrid.TryToFindGridCell(cellInfo);
                    if (gridCell != null)
                    {
                        string columnHeader = gridCell.Column.Header.ToString();
                        int    rowIndex     = dataGrid.Items.IndexOf(cellInfo.Item);

                        selectedCellsCoordinates.Append(string.Format("[{0},{1}] ", columnHeader, rowIndex));
                    }
                }

                this.DisplayAdditionalInfo(dataGrid);

                StatusBarTextBox.Text = selectedCellsCoordinates.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.GetType().Name + ": " + ex.Message, "Error occured during selecting cells", MessageBoxButton.OK, MessageBoxImage.Error);
                Logger.WriteLogException(ex.GetType().Name + ": " + ex.Message);
            }
        }