Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / January 2008

Tip: Looking for answers? Try searching our database.

How do you get an Excel Range in a TextBox?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pinkfloydfan - 21 Jan 2008 13:53 GMT
Hi again

My C# Form is part of a .xll .  I have managed to get the Form to open
up but now what I want to do for one of the TextBoxes is have the user
input an Excel range which can set by clicking a cell/range back in
the calling session of Excel.

So, if the user clicked on cell $A$1 then the TextBox would show the
address of that cell.

Does anybody have any idea how to do this please?

Thanks a lot
Lloyd

p.s. I am using ExcelDna to make my code visible to Excel.
Nicholas Paldino [.NET/C# MVP] - 21 Jan 2008 16:26 GMT
Lloyd,

   The only way I can think of doing this would be to set up an event
handler for the workbook/worksheets to see if the selection changes once
your form is opened (you should be able to get it through the application
instance that is passed to your form, or made available to you through some
other mechanism).

   When your event fires, you update the text in the textbox.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> Hi again
>
[quoted text clipped - 12 lines]
>
> p.s. I am using ExcelDna to make my code visible to Excel.
pinkfloydfan - 22 Jan 2008 17:29 GMT
Thanks Nicholas

Having reviewed my project and your comments I now realise that I need
to have a handle to the calling application instance (otherwise I'll
never be able to paste the results back there)...I did try the Parent
property of the Form but that returned null so now I haven't got a
clue how you find that out.

Can you please tell me?

Thanks a lot
Lloyd
Nicholas Paldino [.NET/C# MVP] - 22 Jan 2008 18:11 GMT
Lloyd,

   You are going to have to have the caller that exposes the form pass the
reference somehow to your form.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> Thanks Nicholas
>
[quoted text clipped - 8 lines]
> Thanks a lot
> Lloyd

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.