|
declare the variable as shered variable so it can be accessed and modified. For example
Public Class Utility<br />
Public Shared SharedVariable As Integer<br />
End Class
hope this helps
|
|
|
|
|
Use a property
Dim strVar As String = "la la la"
Public Property SharedMyVariableWithTheWorld() As String
Get
Return strVar
End Get
Set(ByVal value As String)
strVar = value
End Set
End Property
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
No no no, not how to do it!
I can drag and drop lines between list boxes no problem either as a move or a copy and I have got it to check that the item does not exist in the target box BUT.....
Where I am stuck is that if I drag a line, and drop it in the SAME box, it checks that it is there and does nothing EXCEPT if it is a move, rather than a copy, the line has already been removed from the source box.
The boxes are in separate child forms (of the same type) in a MDI comtainer. Looking at the properties of sender it gives the handle - which actually would be useful - if I could get at it. If I can see this information by hovering over the sender, why can I not get at it with intellisense?
Does any one have any ideas how (otherwise) I can differential between the source and target list boxes?
What I find a bit strange is that the list still seems to contain the string being dragged, even though it was removed in the MouseMove routine.
If (e.Effect = DragDropEffects.Copy Or e.Effect = DragDropEffects.Move) Then
'See if the name is already in the list
If lstCollection.FindStringExact(item) = ListBox.NoMatches Then
'The font does not exist in the list
If (indexOfItemUnderMouseToDrop <> ListBox.NoMatches) Then
'There is something under the mouse so insert
Me.lstCollection.Items.Insert(indexOfItemUnderMouseToDrop, item)
Else
'There is nothing under the mouse so add
Me.lstCollection.Items.Add(item)
End If
End If
End If
This is where it is removed
' If the drag operation was a move then remove the item.
If (dropEffect = DragDropEffects.Move) Then
lstCollection.Items.RemoveAt(indexOfItemUnderMouseToDrag)
' Select the previous item in the list as long as the list has an item.
If (indexOfItemUnderMouseToDrag > 0) Then
lstCollection.SelectedIndex = indexOfItemUnderMouseToDrag - 1
ElseIf (lstCollection.Items.Count > 0) Then
' Selects the first item.
lstCollection.SelectedIndex = 0
End If
End If
Thanks
David
|
|
|
|
|
Hello,
You can try out this code. I have used two Listboxes on a form.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As Integer
For i = 0 To 19
Me.ListBox1.Items.Add("Item " & (i + 1).ToString)
Next
End Sub
Private Sub ListBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown
Try
ListBox1.DoDragDrop(ListBox1.SelectedItem, DragDropEffects.Copy)
Catch ex As Exception
MsgBox("Drag Error: " & ex.Message)
End Try
End Sub
Private Sub ListBox2_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox2.DragDrop
ListBox2.Items.Add(e.Data.GetData(DataFormats.Text))
End Sub
Private Sub ListBox2_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox2.DragEnter
If e.Data.GetDataPresent(DataFormats.Text) Then
e.Effect = DragDropEffects.Copy
Else
MessageBox.Show("No Text Present")
e.Effect = DragDropEffects.None
End If
End Sub
I believe this should assist you.
Regards
Sumit Gupta
|
|
|
|
|
Hi Sumit, thanks for responding but it is not quite what I am trying to determine. I already have code that deals with that. What I need to know is how to identify which list box is the source and which is the target, bearing in mind that they are on different forms which are both identical children of the MDI parent.
David
|
|
|
|
|
In the ondrag event you can inspect e to determine the source. I did not read through the lot but identifying the source should be no problem. You could then set a flag that is external to both forms, inspect the flag when dropping. I have done this in a single form but not MDI.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Not at all a bad idea that. I will give it a whirl. Thanks.
David
|
|
|
|
|
Hi All!
I'm still wading into a long prepared-for project of mine. I've just hit the WYSIWYG HTML editor section and am already stuck. I'm using the following method to activate designmode in a WebBrowser control:
MyWebBrowser.Document.DesignMode = "On"
And then I load the attributes of the ActiveElement (The currently selected HTML element) into a PropertyGrid for editing. My problem is that while ActiveElement works with Buttons, TextBoxes and suchlike in which there is text to edit. It doesn't work with images and other elements that cannot be visually edited in designmode. the resize box appears around the image and drag-drop resizing works fine but the ActiveElement never shifts to the selected element. Any ideas on how to obtain the selected element regardless of it's type?
Thanks!
MrWolfy
modified on Wednesday, October 22, 2008 2:58 PM
|
|
|
|
|
I don't what you're execting with the MSHTML editor. It's not a full-fledged HTML editor. It allows you to do simple editing of the document, that's all. If there's some other editing you want to do outside of what's exposed, you'll have to implement your own editor extensions for that using the Win32 IHtmlEditDesigner[^] interface, which you'll find just about impossible to use from VB.
|
|
|
|
|
Hi and Thanks!
Ok! Thanks for the Link! I guess I'll have to do some more research!
Thanks Again!
MrWolfy
|
|
|
|
|
Hi Folks
Please excuse me if this is an incredible ingnorant question.
I've got 2 linklabels, Next and Previous. I'm using these to move through the images saved in my dataset.
However, looking up Linklabels in help you should be able to do something like LinkLabel1.Link.LinkData in order to set the Data Source. However I'm not getting this option after Link. All I'm getting is Link.Equals or Link.ReferenceEquals?
Can anyone help please?
Thanks alot
Kris MCP
|
|
|
|
|
Sounds like you're using the class instead of the instance.
The instance has Links collection and every item in that collection has LinkData property. LinkLabel.Link is a type used in Links collection.
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
Hi Mike
Sorry for the delay had one of those days!
Thanks for replying but I'm now totally confused. I've read your article and also read up on Instances withing VS 2005. However, there seems to be numerous types, ie, constructor, Property, Method etc.
Please can you offer a little more advise. Yes, I am newly qualified hence being lost.
Thanks alot
Kris
Kris MCP
|
|
|
|
|
No proble,
What I meant is that you possibly don't have an instance for the linklabel when you try to write the method call. That's why you would see only static methods. Try for example something like this:
LinkLabel linkLabel = new LinkLabel()
linkLabel.Text = "Some text"
linkLabel.Links(0).LinkData = "Some data"
linkLabel.Links.Add(0,4, "www.somewhere.xyz")
Mika
P.s. The article link is just part of my signature so it wasn't actually meant to help in your case. Just *advertising*. Glad you read it though
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
Hi Mike
Thanks alot for getting back to me. I've managed to work it by moving through the BindingSource once the linklabel's Click event is raised.
Whilst we're advertising I'd love some comments on my website, from an expert of cause.
Thanks again for your help
www.ktechprogramming.co.uk
Kris
Kris MCP
|
|
|
|
|
No problem,
I had a look at your website and it was very nice. I must admit that I really know nothing about horses but I love to ride.
The only thing that comes in mind is that if you could have permission from your clients to add their names to your website it could have a positive effect for you and your client (add a little story about each client providing some special info they are proud of).
Mika
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
Thanks alot for that! Good idea.
Kris
Kris MCP
www.ktechprogramming.co.uk
|
|
|
|
|
No problem ,
Mika
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
I have hit a wall with my application. I am having problems when dealing with a LONG column in the database. I am getting errors when using the data adapters for either ODBC or OLE (tried both) when the value in one of the LONG columns reaches over a certain threshold length. I try to use the FILL command to get the data from the data provider and into a DataSet or DataTable to then display in a window for the user. However, this causes an error as I mentioned. So I have spent too much time digging and trying to get past this but cannot find a solution.
Do I need to create my own override for the FILL command so it handles LONG columns? I would have expected this to be already handled by MS Framework - perhaps not!?
Anyone have time to help me? I would REALLY appreciate it!
I am trying to access a SQL Anywhere database file (dbf) and provide a fully functional database explorer to the users so we can perform various tasks easier.
Here is my ODBC test code that fails at the FILL line...
Dim conn As New Odbc.OdbcConnection("DSN=" & "client_x" & ";UID=" & "STT" & ";PWD=" & "NEED2CHANGE" & ";")
Dim dr As Odbc.OdbcDataReader
Dim strSQL As String = "select b.name, b.row_id, b.inactive_flg, b.script from SIEBEL.S_APPL_WEBSCRPT b where b.row_id = '1-K3E-1IYQ'"
Dim dt As New DataTable
Dim dg As New DataGrid
Dim cmd As New Odbc.OdbcCommand(strSQL, conn)
Dim vals() As String
Dim myAdaptor As New Odbc.OdbcDataAdapter(strSQL, conn)
myAdaptor.AcceptChangesDuringFill = True
myAdaptor.Fill(dt)
Here is my OLE test code that works when I query only for 1 record, but when multiple records are returned I cannot get the FILL command to work at all!
Dim ConnString As String
Dim Connect As ADODB.Connection
Dim RS As New ADODB.Recordset
Dim DataGrid1 As New DataGridEX
Dim dt As New DataTable
Dim ds As New DataSet
Dim custDA As New OleDb.OleDbDataAdapter
Dim strSQL As String = "select b.name, b.row_id, b.inactive_flg, b.script from SIEBEL.S_APPL_WEBSCRPT b"
ConnString = "DSN=" & "client_x" & ";UID=" & "SST" & ";PWD=" & "NEED2CHANGE" & ";"
Connect = New ADODB.Connection
Connect.CursorLocation = ADODB.CursorLocationEnum.adUseServer
Connect.Open(ConnString)
RS.CacheSize = 10
RS.Open(strSQL, Connect, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText)
custDA.Fill(dt, RS)
Dim f As New Form
Dim t As New TextBox
t.Multiline = True
f.Controls.Add(t)
t.Dock = DockStyle.Fill
t.Text = RS.Fields(3).GetChunk(RS.Fields(3).ActualSize)
Thanks!
John Wadleigh
Siebel Expert
|
|
|
|
|
I think that a LONG column in the database cannot fit inside the limits of the mapped column under ODBC or OLE. It's possible that the column would have to be treated like a binary object column, such as an image, where you have to get the contents of the column using a stream process. That's why I said using the database-specific provider would provide better compatibility.
|
|
|
|
|
how to edit appconfig in windows application(C#)??
i am using this code but not getting success please help me
Code:-
Properties.Settings.Default.DestinationDrives = "ppc";
Properties.Settings.Default.Save();
Piyush Vardhan Singh
p_vardhan14@rediffmail.com
http://holyschoolofvaranasi.blogspot.com
http://holytravelsofvaranasi.blogspot.com
|
|
|
|
|
Why post C# questions here? (As well as the proper forum)
Bob
Ashfield Consultants Ltd
|
|
|
|
|
if u know the answer then help me.
thanks
Piyush Vardhan Singh
p_vardhan14@rediffmail.com
http://holyschoolofvaranasi.blogspot.com
http://holytravelsofvaranasi.blogspot.com
|
|
|
|
|
Too late - you have been given the answer in the correct forum. It is a pain when people post the same question to multiple forums, and even more so when it is OBVIOUSLY the wrong forum.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Use common sense and don't cross post.
|
|
|
|