Spreadsheet Control select a user's active cell/column

7 posts, 0 answers
  1. Nathan
    Nathan avatar
    5 posts
    Member since:
    Aug 2019

    Posted 23 Aug 2019 Link to this post

    I am having trouble just trying to get a user's currently selected cell when using this control.

    https://docs.telerik.com/devtools/winforms/controls/spreadsheet/features/ui-working-with-selection.html

    from this page I can't even get this to work with my control (Selection seems to not be found so I Underlined and Bolded it)

    Selection selection_2 = this.radSpreadsheet.SpreadsheetElement.ActiveWorksheetEditor.Selection;

    selection_2.Select(new CellIndex(0, 0), false);

    yes I have all the required References added to my project and form.

     

  2. Nathan
    Nathan avatar
    5 posts
    Member since:
    Aug 2019

    Posted 23 Aug 2019 in reply to Nathan Link to this post

    here is my code

    Telerik.WinForms.Controls.Spreadsheet.Worksheets.Selection selection = this.radSpreadsheet1.SpreadsheetElement.ActiveWorksheetEditor.Selection;

    MessageBox.Show(selection.ActiveCellIndex.ToString());

    here is my build error

    The type 'System.Windows.IWeakEventListener' is defined in an assembly that is not referenced. You must add a reference to assembly 'WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.


  3. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    4132 posts

    Posted 26 Aug 2019 Link to this post

    Hello, Nathan,  

    Following the provided information, I was unable to reproduce the issue you are facing. Please refer to the following screenshot:

    I have the following assemblies added to the project and it runs as expected:

    • Telerik.WinControls
    • Telerik.WinControls.RadSpreadsheet
    • Telerik.WinControls.UI
    • Telerik.Windows.Documents.Spreadsheet
    • TelerikCommon

    You can find attached my sample project for your reference. Am I missing something? Do I need to perform any changes in order to replicate the problem you are facing?

    I am looking forward to your reply.

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  4. Nathan
    Nathan avatar
    5 posts
    Member since:
    Aug 2019

    Posted 26 Aug 2019 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Interesting your project works fine for me.  I had to upgrade your project to 2018.2.621.  I run Telerik in VS 2013.  I don't have the Excel Ribbon in my other App.  I removed it from your app and it still works.  I also have plenty of other libraries.  Here is all the libraries I have included in my form.  Perhaps there is some conflict.  I look forward to your reply.

     

    All my code & attached screenshots of the reference folder.  FYI Most is commented out.

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using Telerik.WinControls;
    using System.Net;
    using System.Text.RegularExpressions;
    using Telerik.WinControls.UI;
    using Telerik.WinControls.Spreadsheet;
    using Telerik.Windows.Documents.Spreadsheet;
    using Telerik.Windows.Documents.Core;
    using Telerik.Documents.SpreadsheetStreaming;
    using Telerik.Windows.Data;
    using Telerik.Windows.Zip;
    using Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml.Xlsx;
    using System.IO;
    using System.Windows;

     

        public partial class ToolsURLChecker : Telerik.WinControls.UI.RadForm
        {
            public ToolsURLChecker()
            {
                InitializeComponent();
            }

            private void radButton1_Click(object sender, EventArgs e)
            {
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    var formatProvider = new XlsxFormatProvider();
                    using (Stream input = new FileStream(openFileDialog1.FileName, FileMode.Open))
                    {
                        radSpreadsheet1.Workbook = formatProvider.Import(input);
                    }
                }
            }

            private void ToolsURLChecker_Load(object sender, EventArgs e)
            {
                radSpreadsheet1.ElementTree.EnableApplicationThemeName = false;
            }

            private void btnPageTitles_Click(object sender, EventArgs e)
            {
                Telerik.WinForms.Controls.Spreadsheet.Worksheets.Selection selection = this.radSpreadsheet1.SpreadsheetElement.ActiveWorksheetEditor.Selection;
                MessageBox.Show(selection.ActiveCellIndex.ToString());
                //MessageBox.Show(radSpreadsheet1.ActiveSheet.Name);
               
                //{

                /*
                try
                {
                    WebClient wc = new WebClient();
                    string html = wc.DownloadString("https://Nathan.sertaretailers.com");

                    Regex x = new Regex("<title>(.*)</title>");
                    MatchCollection m = x.Matches(html);

                    if (m.Count > 0)
                    {
                         MessageBox.Show(m[0].Value.Replace("<title>", "").Replace("</title>", ""));
                    }
                    else
                         MessageBox.Show("");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Could not connect. Error:" + ex.Message);
                }
                 */
                //}
            }

            private void btnStatusCodes_Click(object sender, EventArgs e)
            {
                /* 
                Uri urlCheck = new Uri("https://Nathan.sertaretailers.com");
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlCheck);
                request.Timeout = 15000;

                HttpWebResponse response;
                try
                {
                    response = (HttpWebResponse)request.GetResponse();
                    MessageBox.Show("Code:  " + response.StatusCode + "  Desc:  " + response.StatusDescription);
                    
                }
                catch (Exception)
                {
                    MessageBox.Show("UH OH");
                }
                */
            }
        }

     

     

  5. Nathan
    Nathan avatar
    5 posts
    Member since:
    Aug 2019

    Posted 26 Aug 2019 in reply to Nathan Link to this post

    I added your form to my Project and it no longer works.

    I get the same build error

    Error1The type 'System.Windows.IWeakEventListener' is defined in an assembly that is not referenced. You must add a reference to assembly 'WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.C:\Users\nathan.herritt\Google Drive\GWA_Projects\GWA_ERP\GWA_ERP\ToolsURLCheckerV2.cs2313GWA_ERP

     

  6. Nathan
    Nathan avatar
    5 posts
    Member since:
    Aug 2019

    Posted 26 Aug 2019 in reply to Nathan Link to this post

    oh my I was missing the reference to WINDOWSBASE.
  7. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    4132 posts

    Posted 27 Aug 2019 Link to this post

    Hello, Nathan,  

    I am glad that the problem you were facing is now resolved. Usually, the WindowsBase assembly is present in the project after creation of the form and adding the RadSpreadsheet control to it. Hence, it is not necessary to add it explicitly. I suppose that you have removed it by mistake once you dragged and dropped the control onto the form. 

    Should you have further questions please let me know.

     

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top