Hi everyone,
I'm trying to code an event and seem to be stuck on something that might
seem pretty simple (I am a newbie...)
I have two textboxes on a form, I have a button on a form that is
supposed to copy selected text.
When I click the button I want the selected text to be copied into the
clipboard. I can do this by saying:
Private Sub Copy_Click(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles Copy.Click
If TextBox1.Select ionLength > 0 Then
My.Computer.Cli pboard.SetText( TextBox2.Select edText,
TextDataFormat. Text)
End If
If TextBox2.Select ionLength > 0 Then
My.Computer.Cli pboard.SetText( TextBox1.Select edText,
TextDataFormat. Text)
End If
End Sub
But I want the code to know which textbox has text selected in it without
me having to specify it. Suppose I had more textboxes for example it
would be tiresome to write the if statement for all the textboxes (or any
control for that matter)...
Is there a way to do this without specifying the control name all the
time, I would love to learn how...
Any help is welcome,
Thanks in advance to anyone willing to help. 4 1250
Hi everyone,
Sorry... I just saw something wrong in my code and have to update the
post...
I'm trying to code an event and seem to be stuck on something that might
seem pretty simple (I am a newbie...)
I have two textboxes on a form, I have a button on a form that is
supposed to copy selected text.
When I click the button I want the selected text to be copied into the
clipboard. I can do this by saying:
Private Sub Copy_Click(ByVa l sender As System.Object, ByVal e As_
System.EventArg s) Handles Copy.Click
If TextBox1.Select ionLength > 0 Then
My.Computer.Cli pboard.SetText( TextBox1.Select edText,_
TextDataFormat. Text)
End If
If TextBox2.Select ionLength > 0 Then
My.Computer.Cli pboard.SetText( TextBox2.Select edText,_
TextDataFormat. Text)
End If
End Sub
But I want the code to know which textbox has text selected in it
without me having to specify it. Suppose I had more textboxes for
example it would be tiresome to write the if statement for all the
textboxes (or any control for that matter)...
Is there a way to do this without specifying the control name all the
time, I would love to learn how...
Any help is welcome,
Thanks in advance to anyone willing to help.
TheGanjaMan wrote: Hi everyone, Sorry... I just saw something wrong in my code and have to update the post... I'm trying to code an event and seem to be stuck on something that might seem pretty simple (I am a newbie...)
I have two textboxes on a form, I have a button on a form that is supposed to copy selected text. When I click the button I want the selected text to be copied into the clipboard. I can do this by saying:
Private Sub Copy_Click(ByVa l sender As System.Object, ByVal e As_ System.EventArg s) Handles Copy.Click If TextBox1.Select ionLength > 0 Then My.Computer.Cli pboard.SetText( TextBox1.Select edText,_ TextDataFormat. Text) End If If TextBox2.Select ionLength > 0 Then My.Computer.Cli pboard.SetText( TextBox2.Select edText,_ TextDataFormat. Text) End If End Sub
But I want the code to know which textbox has text selected in it without me having to specify it. Suppose I had more textboxes for example it would be tiresome to write the if statement for all the textboxes (or any control for that matter)... Is there a way to do this without specifying the control name all the time, I would love to learn how...
Any help is welcome, Thanks in advance to anyone willing to help.
Maybe something like using a for each loop to check every
control(textbox ) to see if something is selected.
--
Rinze van Huizen
C-Services Holland b.v
Hello, GanjaMan,
I don't know anything about "My.Computer.Cl ipboard", but I think what
you are doing here will not give you what you want. For example, if
both TextBoxes have selected text, you will always get the text in TextBox2.
You might consider setting a module scope string to the selected text in
the validate event of the TextBox, and using that in your button click
event.
Something like:
Private mstrSelectedTex t As String = ""
Private Sub TextBox_Validat ed(ByVal sender As Object, _
ByVal e As System.EventArg s) _
Handles TextBox1.Valida ted, _
TextBox2.Valida ted
mstrSelectedTex t = DirectCast(send er, TextBox).Select edText
End Sub
and then set the clipboard text using mstrSelectedTex t. If you have a
lot of TextBoxes, you can set the handler in a loop using AddHandler.
Cheers,
Randy
TheGanjaMan wrote: Hi everyone, Sorry... I just saw something wrong in my code and have to update the post... I'm trying to code an event and seem to be stuck on something that might seem pretty simple (I am a newbie...)
I have two textboxes on a form, I have a button on a form that is supposed to copy selected text. When I click the button I want the selected text to be copied into the clipboard. I can do this by saying:
Private Sub Copy_Click(ByVa l sender As System.Object, ByVal e As_ System.EventArg s) Handles Copy.Click If TextBox1.Select ionLength > 0 Then My.Computer.Cli pboard.SetText( TextBox1.Select edText,_ TextDataFormat. Text) End If If TextBox2.Select ionLength > 0 Then My.Computer.Cli pboard.SetText( TextBox2.Select edText,_ TextDataFormat. Text) End If End Sub
But I want the code to know which textbox has text selected in it without me having to specify it. Suppose I had more textboxes for example it would be tiresome to write the if statement for all the textboxes (or any control for that matter)... Is there a way to do this without specifying the control name all the time, I would love to learn how...
Any help is welcome, Thanks in advance to anyone willing to help.
Hi Randy...
Thanks for the input, I think I'm going to get it solved with the
directcast keyword...
Thanks for your help...
"R. MacDonald" <sc****@NO-SP-AMcips.ca> wrote in
news:44******** *************** @news.wanadoo.n l: Hello, GanjaMan,
I don't know anything about "My.Computer.Cl ipboard", but I think what you are doing here will not give you what you want. For example, if both TextBoxes have selected text, you will always get the text in TextBox2.
You might consider setting a module scope string to the selected text in the validate event of the TextBox, and using that in your button click event.
Something like:
Private mstrSelectedTex t As String = ""
Private Sub TextBox_Validat ed(ByVal sender As Object, _ ByVal e As System.EventArg s) _ Handles TextBox1.Valida ted, _ TextBox2.Valida ted mstrSelectedTex t = DirectCast(send er, TextBox).Select edText End Sub
and then set the clipboard text using mstrSelectedTex t. If you have a lot of TextBoxes, you can set the handler in a loop using AddHandler.
Cheers, Randy This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: AK |
last post by:
Hi, I recently read an advice here that one should try to use make and
version control system even if you're the only one working on the
program. Is that a good advice? How many of you do that?
Thanks,
-AK
|
by: Tom |
last post by:
hi guys I have a problem a event bubble that isn't working.
isn't working= I've opened up a handle in my user control but when I try to
use it ie.
ok I am trying to assign an event handler from Form1 to a user control's
event that I had previously made available.. but something's not right.
after the code is ran. The control does not see the BubbleClick event that
is assigned
bubblecontrol = new eventbubble();
|
by: Gilles T. |
last post by:
I have calendar control in Javascript including in the Head of mu page:
<script charset="iso-8859-1" language="JavaScript"
src="popcalendar.js"></script>
I call this calendar popup with a image link button and working very good:
<asp:Textbox CssClass="edit_item" id="txtEditDernieresResolutions"
runat="server" width="80"/>
<a href='javascript:showCalendar(frmForm.imgDernieresResolutions,...
|
by: clintonG |
last post by:
I'm using an .aspx tool I found at but as nice as the interface is I
think I need to consider using others. Some can generate C# I understand.
Your preferences please...
<%= Clinton Gallagher
http://forta.com/books/0672325667/
|
by: Sevu |
last post by:
I am working with ASP.NET.I am using ReportViwer Control to show my
report.I like to add dropdownlist with in the reportviewer control. (
Not top to the control some thing like that).I need to place dropdown
near to Export link ( Excel and PDF Export).Is it possible to add at
the dropdown list with in report viewer control?. I found the property
as ReportViewer.Controls.Add.But its not working.Please help me.
Regards,
S.Sevugan.
| |
by: mc |
last post by:
I'm writing an app for managing Task Lists, I'm trying to add some
controls to a form that I can use to link tasks, my original intention
was to: -
Add two list boxes, one listing "all Tasks" and the other listing
"Linked Tasks", I have two buttons which in javascript move items from
the first list into the second.
Then when a user clicks a thrid button I would like to save this data.
|
by: monomaniac21 |
last post by:
Hi all
we are thinking of using a version control system at work. I was
wondering what are some of the issues we should take into
consideration when deciding upon which one to use? and which one/s you
would recommend?
thanks
marc
|
by: Dog Ears |
last post by:
I've got a windows form that monitors the status of employees it polls a database every 2 seconds to fetch updates then update a underlying
dataset bound to a grid using Invoke to marshal to the gui thread.
What pattern should I be using now I'm upgrading to .net 2.0? APM, async
delegates and BeginInvoke or Thread.Start etc...?
Should I be creating a single thread manulally (or using threadpool) and and
setting the polling on an...
|
by: Steve Swift |
last post by:
I don't have a particular webpage to point you to; I thought about this
whilst walking my dog this morning and don't have an example page. That
said, this question doesn't really require a "working" example.
I have a form with two <SELECTcontrols. Both contain:
onChange="this.form.submit()"
So whichever one changes, my POST data contains both elements. How can I
know which one changed?
|
by: =?Utf-8?B?Qkw=?= |
last post by:
I am in a problem to access user control(.ascx) on a .aspx page
the following is my scenario
I have following directory structure -
Autoboom
- workshop
-- WSFirst
-showroom
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |