473,406 Members | 2,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

[VB2005EE] accessing control-specific functions via form's ActiveControl

I got serveral textboxes in a form and want to copy/cut/paste text to
clipboard from currently selected (focused) textbox.

It's simple to cut/copy/paste when using specified control directly ie
Me.TextBox1.Cut()

But there's no .Cut() function when i try to use Me.ActiveControl. Is the a
way to access textbox'es .Cut() via ActiveControl knowing that it's a
textbox object?

I also tried an other way:
Clipboard.SetText(Me.ActiveControl.Text)
and
Clipoboard.SetText(Me.ActiveControl.Text.ToString( ))
but it produces errors.

Does anyone knows a solution?
Thx, Aph

May 11 '06 #1
4 1372
Aph,

Here is one way:

Dim tbox As TextBox

tbox = CType(Me.ActiveControl, TextBox)
tbox.SelectAll()
tbox.Copy()

Kerry Moorman
"Aphazel" wrote:
I got serveral textboxes in a form and want to copy/cut/paste text to
clipboard from currently selected (focused) textbox.

It's simple to cut/copy/paste when using specified control directly ie
Me.TextBox1.Cut()

But there's no .Cut() function when i try to use Me.ActiveControl. Is the a
way to access textbox'es .Cut() via ActiveControl knowing that it's a
textbox object?

I also tried an other way:
Clipboard.SetText(Me.ActiveControl.Text)
and
Clipoboard.SetText(Me.ActiveControl.Text.ToString( ))
but it produces errors.

Does anyone knows a solution?
Thx, Aph

May 11 '06 #2
Hi,

Form.ActiveControl is of type Control, so you need to cast it manually:

~
If TypeOf Me.ActiveControl Is TextBox Then
DirectCast(Me.ActiveControl, TextBox).Cut()
End If
~

Roman
May 11 '06 #3
Thx for your advice Kerry :) however I've always liked this style more:
DirectCast(Me.ActiveControl, TextBox).Cut() It's just my personal preference but I don't like to declare additionas dims
for such actions.
Which way is better? I'm not the one to judge here, not enough knowledge ;)
It's just IMHO code looks better this way. Neat, I'd say. :D

Aph
Here is one way:

Dim tbox As TextBox

tbox = CType(Me.ActiveControl, TextBox)
tbox.SelectAll()
tbox.Copy()

Kerry Moorman


May 11 '06 #4
Sup :)
This is exaclty what I wanted. THX, I owe you man :)))
I used to use similar stuff in Delphi and BCB, just couldn't find easy
enough what's the syntax in VB.Net so I've dediced to ask here.

Aph
~
If TypeOf Me.ActiveControl Is TextBox Then
DirectCast(Me.ActiveControl, TextBox).Cut()
End If
~


May 11 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: AdamM | last post by:
Hi all, When I run my VbScript, I get the error: "ActiveX component can't create object: 'getobject'. Error 800A01AD". Any ideas what I did wrong? Here's my VBScript: dim o set...
6
by: evandelagrammaticas | last post by:
Hi all. I have spent the better part of a day scouring the newsgroups and I am sure that I must have come across the solution a number of times - but I am still a real newbie at asp.net so please...
5
by: Siva | last post by:
Hello I have a dropdownlist inside the gridview as a template column defined as follows: <asp:TemplateField HeaderText="Choose Location"> <ItemTemplate> <asp:DropDownList ID="ddlChooseLoc"...
0
by: =?Utf-8?B?QmFyZW4=?= | last post by:
Hi! I have created a ASP.NET web application and accessing the same in SharePoint Portal Server using PageViewer Control. My application has a search, wherein I am sending the search string as a...
4
by: imranabdulaziz | last post by:
Dear All, I am using asp.net2.0, C#, sql2005 using Visual studio 2005 Let Me explain the scenario I have checkboxlist containg 15 field. Based on no of checked field . I created...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.