|
I written an application (With the help of other people) to grab information from a SQL database, and display it on screen, so that is is editable, deletable and amendable.
How would I go about pasting a set line (Of the Data Grid) into an underlying application (Like a webform?)
Any help is appreciated.
Cheers
|
|
|
|
|
What do you mean by an "underlying" application? A web form is not an application, that would rather be a browser...
Perhaps you should explain what it is that you are trying to accomplish, instead of asking for what you think may be the solution...
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
If you want to achieve this you are going to have to manage the copy paste operation yourself (or at least the copy part). You will need to read the row from the data grid, construct an object (probably a delimited string) for the data and place it in the clipboard.
The paste part is up to your target.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi experts,
i am developing a window application, using VS 2005, i created a user control that contain a Combobox and error provider for my combo.
Everything worked just fine until i needed to use the event SelectedindexChange, in fact, in my form i have my user control(containing Combo box) and a checked list box. For each value in my Combo box i have to load different values into my checked list box
Therefore, i need to use the event selectedindexchange in my form
can anyone teach me please how to create an event in my form to fire a function in my usercontrol when the index is changed? If there is another way hope to share it.
the code of my user control (if there is any remarks or anything that i could be written much better or missing i will be thankful to tell me)
Public Class All_In_One_ComboBox
Private Err_Msg As String
Private Index As Integer
Private Err As Boolean = False
Private Back_Color As Color = Color.White
Private Fore_Color As Color = Color.Black
Private _Font As New Font("Microsoft Sans Serif", 12, FontStyle.Regular, GraphicsUnit.Point)
Public Property My_Back_Color() As Color
Get
My_Back_Color = Back_Color
End Get
Set(ByVal value As Color)
Me.My_ComboBox.BackColor = value
End Set
End Property
Public Property My_Fore_Color() As Color
Get
My_Fore_Color = Fore_Color
End Get
Set(ByVal value As Color)
Me.My_ComboBox.ForeColor = value
End Set
End Property
Public Property My_Text() As String
Get
My_Text = Trim(Me.My_ComboBox.Text)
End Get
Set(ByVal Value As String)
Me.My_ComboBox.Text = Value
End Set
End Property
Public Property My_Index() As Integer
Get
My_Index = Index
End Get
Set(ByVal Value As Integer)
Index = Value
End Set
End Property
Public Property My_Err_Rslt() As Boolean
Get
My_Err_Rslt = Err
End Get
Set(ByVal value As Boolean)
Err = value
End Set
End Property
Public Property My_Err_Msg() As String
Get
My_Err_Msg = Err_Msg
End Get
Set(ByVal value As String)
Err_Msg = value
End Set
End Property
Public Property My_Font() As Font
Get
My_Font = _Font
End Get
Set(ByVal value As Font)
Me.My_ComboBox.Font = value
End Set
End Property
Private Sub My_ComboBox_BackColorChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles My_ComboBox.BackColorChanged
Back_Color = Me.My_ComboBox.BackColor
End Sub
Private Sub My_ComboBox_FontChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles My_ComboBox.FontChanged
_Font = Me.My_ComboBox.Font
End Sub
Private Sub My_ComboBox_ForeColorChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles My_ComboBox.ForeColorChanged
Fore_Color = Me.My_ComboBox.ForeColor
End Sub
Private Sub All_In_One_ComboBox_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
Me.My_ComboBox.Width = Me.Width - 20
Me.My_ComboBox.Height = Me.Height
End Sub
Private Sub My_ComboBox_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles My_ComboBox.KeyUp
Call Me.Auto_complete(e)
End Sub
Public Sub My_ComboBox_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles My_ComboBox.SelectedIndexChanged
Index = Me.My_ComboBox.SelectedIndex
End Sub
Private Sub My_ComboBox_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles My_ComboBox.Validating
If Me.My_ComboBox.Text = "" Then
Me.Err_Msg_Prv.SetError(Me.My_ComboBox, My_Err_Msg)
Err = True
Else
Me.Err_Msg_Prv.SetError(Me.My_ComboBox, "")
Err = False
End If
End Sub
Public Sub Load_Data_In_My_Combo(ByVal My_Data As DataTable, ByVal Column_Name As String)
Me.My_ComboBox.Items.Clear()
Dim i As Integer = 0
While i < My_Data.Rows.Count
Me.My_ComboBox.Items.Add(My_Data.Rows(i).Item(Column_Name))
i = i + 1
End While
End Sub
Public Sub Add_Item(ByVal My_Item As String)
Me.My_ComboBox.Items.Add(My_Item)
End Sub
Public Sub Clear_All_Items()
Me.My_ComboBox.Items.Clear()
End Sub
Private Sub Auto_complete(ByVal e As System.Windows.Forms.KeyEventArgs)
Dim My_String As String
Dim My_Found_String As String
Dim Match_Found As Boolean
If Not Me.My_ComboBox.Text = "" Then 'if the text is not blank then only proceed
If e.KeyCode = Keys.Back Then
Me.My_ComboBox.Text = Mid(Me.My_ComboBox.Text, 1, Len(Me.My_ComboBox.Text) - 1)
End If
If ((e.KeyCode = Keys.Left) Or _
(e.KeyCode = Keys.Right) Or _
(e.KeyCode = Keys.Up) Or _
(e.KeyCode = Keys.Down) Or _
(e.KeyCode = Keys.PageUp) Or _
(e.KeyCode = Keys.PageDown) Or _
(e.KeyCode = Keys.Home) Or _
(e.KeyCode = Keys.End)) Then
Return
End If
Do
My_String = Me.My_ComboBox.Text
Index = Me.My_ComboBox.FindString(My_String)
If (Index > -1) Then '** FOUND SECTION **
My_Found_String = Me.My_ComboBox.Items(Index).ToString()
' Select this item from the list.
Me.My_ComboBox.SelectedIndex = Index
Me.My_ComboBox.SelectionStart = My_String.Length
Me.My_ComboBox.SelectionLength = My_Found_String.Length
Match_Found = True
Else '** NOT FOUND SECTION **
If My_String.Length = 1 Or My_String.Length = 0 Then
Me.My_ComboBox.SelectedIndex = 0
Me.My_ComboBox.SelectionStart = 0
Me.My_ComboBox.SelectionLength = Len(Me.My_ComboBox.Text)
Match_Found = True
Else
Me.My_ComboBox.SelectionStart = My_String.Length - 1
Me.My_ComboBox.SelectionLength = My_String.Length - 1
Me.My_ComboBox.Text = Mid(Me.My_ComboBox.Text, 1, Len(Me.My_ComboBox.Text) - 1)
End If
End If
Loop Until Match_Found
End If
End Sub
Public Event My_Combo_Selected_IndexChange()
Public Sub My_Combo_Selected_Index_Change()
RaiseEvent My_Combo_Selected_IndexChange()
End Sub
Public Sub test() Handles Me.My_Combo_Selected_IndexChange
Index = Me.My_ComboBox.SelectedIndex
MsgBox(Index)
End Sub
End Class
the help that i needed is here:
Public Event My_Combo_Selected_IndexChange()
Public Sub My_Combo_Selected_Index_Change()
RaiseEvent My_Combo_Selected_IndexChange()
End Sub
Public Sub test() Handles Me.My_Combo_Selected_IndexChange
Index = Me.My_ComboBox.SelectedIndex
MsgBox(Index)
End Sub
waelhawari
|
|
|
|
|
Thanks for the excessively long post
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Waoula wrote: can anyone teach me
sure
go to Google and type 'VB.net index changed user control function' in the search box
Don't take any wooden nickels.
|
|
|
|
|
Out of curiosity I did, first hit, this question
When I have used a user control I put all the management for the control in the code behind the control (it worked Ok for the rare occasions I have needed a UC)
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Waoula wrote: can anyone teach me please how to create an event in my form to fire a function in my usercontrol when the index is changed?
You could, but you shouldn't, as the code gets harder to follow and maintain. Handle the even in the form where the control is that causes the event, and from that event handler just call a method (or set a property) in your user conrol.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thanks Guys.
in fact i found it, all i have to do is:
declaring a new event to my user control
Public Event Selected_Index_Changed()
and this
Public Sub My_ComboBox_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles My_ComboBox.SelectedIndexChanged
Index = Me.My_ComboBox.SelectedIndex
RaiseEvent Selected_Index_Changed()
End Sub
so when the combo box change index the user control raiseevent Selected_Index_Changed
this way i can use it in the original form
sorry if my post was to long just wanted to share my ideas and make the code much more better
thanks again.
waelhawari
|
|
|
|
|
Hi gents,
Please provide me a real time example for Delegate.
Regards
Azeem
|
|
|
|
|
|
How to remove white space from middle of string
Iam Using string builder and iam getting the text in string builder-
HI Welcome to India
I want to remove spaces in between and the result shouldbe
HIWelcometoIndia
pls any one help
|
|
|
|
|
Dim asdf As New System.Text.StringBuilder
asdf.AppendLine("this is a test")
asdf.Replace(" ", String.Empty)
MsgBox(asdf.ToString)
|
|
|
|
|
Hi all
I have already posted my article for access permission.
But i would like to know how to give password and username to folder which is created at runtime?
is it possible through coding in vb?
If yes pls help me
Thnaks
monika
|
|
|
|
|
You want to password protect a Windows folder?
|
|
|
|
|
For reasons too boring to go into, I need to make a set of textboxes open depending on the user input.
for example, I have TextBox1, TextBox2, TextBox3 etc up to 7.
I have a combobox that is populated 1 to 7
User selects 6 for example, I want textboxes 1-6 to become visible.
I am trying something like this...
For i = 1 to intNumOfBoxes
TextBox(a).Visible = True
Next
Of course it isn't working!
I tried TextBox & intNumOfBoxes, still no joy.
I know it is late and I am being dim, but any suggestions?
------------------------------------
"I want you to imagine I have a blaster in my hand" - Zaphod Beeblebrox.
"You DO have a blaster in your hand" - Freighter Pilot
"Yeah, so you don't have to tax your imagination too hard" - Zaphod Beeblebrox
|
|
|
|
|
Declare a control TextBox using the contactenated string as the name. I think this works.
Dim oTB as new textbox("textboxname")
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: Dim oTB as new textbox("textboxname")
Doesnt seem to work.
It say "Too many Arguments to Public Sub New()"
However...
I tried this
Dim oTB As New TextBox
For a = 1 To INumOfBox2
oTB.Name = "TextBox"
oTB.Name = oTB.Name & Str(a)
oTB.Visible = True
Next
It accepts it, but doesn't make visible the Text Boxes
------------------------------------
"I want you to imagine I have a blaster in my hand" - Zaphod Beeblebrox.
"You DO have a blaster in your hand" - Freighter Pilot
"Yeah, so you don't have to tax your imagination too hard" - Zaphod Beeblebrox
|
|
|
|
|
I think you will need to use reflections to get at the textbox (or a case statement which is simpler but a kludge)
dim oTB as textbox
Select Case cbo.selectedvalue
case 1....
otb = txtBox1
Dalek Dave wrote: Dim oTB As New TextBox
This instantiates as new textbox which you then assign a name to and discard.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks, I will try that in the morning though, 3.21am and brain starting to fry.
I can see a way of doing it that is long winded, so I hope that your method works!
------------------------------------
"I want you to imagine I have a blaster in my hand" - Zaphod Beeblebrox.
"You DO have a blaster in your hand" - Freighter Pilot
"Yeah, so you don't have to tax your imagination too hard" - Zaphod Beeblebrox
|
|
|
|
|
Well, it should be morning and here is a work around that made me chuckle. It may not be a good one bu it works.
Create a groupbox/panel to hold your combo and 7 text boxes.
Make sure the tab order is sequential within the container - critical
in the on change event of the combo put the following (i had it in a button event for testing)
Dim oCtrl As Control = Me.cboList
Dim iLimit As Int16
iLimit = CInt(cboList.Text)
For i = 1 To iLimit
oCtrl = Me.GetNextControl(oCtrl, True)
Next
If Not IsNothing(oCtrl) Then
oCtrl.Text = iLimit
End If
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
If the textboxes are called TextBox1, Textbox2, etc. you may be able to do something like:
Dim Const TextBoxes() as TextBox = _
{TextBox1, TextBox2, TextBox3, TextBox4, TextBox5, TextBox6, TextBox7} and then do TextBoxes(a).Visible=True
|
|
|
|
|
Thanks, I knew I was on the right track, but I couldn't work out the method!
That works perfectly well, and is exactly what I need!
I was trying to treat the method TEXTBOX as an array, obviously a no no.
Cheers.
Now, onto my next problem...soon
------------------------------------
"I want you to imagine I have a blaster in my hand" - Zaphod Beeblebrox.
"You DO have a blaster in your hand" - Freighter Pilot
"Yeah, so you don't have to tax your imagination too hard" - Zaphod Beeblebrox
|
|
|
|
|
You can create the textboxes as an array control and change the indexes according to your needs, and use this code to make them visible:
for i=1 to numberselected
textbox(i).visible = trun
next i
|
|
|
|
|
Can some1 remind me how I pass a variable from one procedure to another in excel visual basic
|
|
|
|