|
It's C#, and the actual code snipppets are small enough that you can easily convert it VB.NET.
|
|
|
|
|
ok thanks i will make a try
|
|
|
|
|
Message Removed
modified 5-Apr-19 3:56am.
|
|
|
|
|
I'm trying to add a custom tooltip to my datagridview(s). In my research I know that the System.Windows.Forms.DataGridViewCellMouseEventArgs has no mouse hover event so instead I am using System.EventArgs. My problem of course that the mouse hover event only fires once on the datagridview until the user moves the mouse off the control. I need the event to fire each time the user hovers over a new row. Is there a way to reset the hover event on mouse move within the same control? I have searched and cannot find anything on this.
Here is my code which works perfectly but as mentioned only fires once.
Private Sub dtgNewMrs_cellMouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles dtgNewMRs0.MouseHover, dtgNewMRs1.MouseHover, dtgNewMRs2.MouseHover, dtgNewMRs3.MouseHover, dtgNewMRs4.MouseHover, dtgNewMRs5.MouseHover
Dim remMRNum As String
Dim remMRLin As String
Dim tTip As String = Nothing
Dim tCount As Integer = 1
Dim grvScreenLocation As Point = sender.PointToScreen(sender.Location)
Dim tempX As Integer = DataGridView.MousePosition.X - grvScreenLocation.X + sender.Left
Dim tempY As Integer = DataGridView.MousePosition.Y - grvScreenLocation.Y + sender.Top
Dim hit As DataGridView.HitTestInfo = sender.HitTest(tempX, tempY)
Dim chkRemarks As DataTable = rSet.Tables("RemarksMR")
With sender
remMRNum = .Rows(hit.RowIndex).Cells(3).Value
remMRLin = .Rows(hit.RowIndex).Cells(4).Value
Dim tQry = (From rems In chkRemarks.AsEnumerable()
Where rems.Field(Of String)("MR_Num") = remMRNum And
rems.Field(Of String)("MR_Line") = remMRLin).ToList()
Dim r = From t In tQry
Select t
If r.Count > 0 Then
For Each row As DataRow In r
tTip = tTip & Str(tCount) & ". " & row.Item(3) & Chr(13)
tCount += 1
Next
End If
End With
remTip.SetToolTip(sender, tTip)
|
|
|
|
|
Have you investigated How to: Add ToolTips to Individual Cells in a Windows Forms DataGridView Control (google) in which case you do not have to use Hover.
|
|
|
|
|
I've tried this implementation and it works but I am wondering if there
are any underlying problems with it; ie Loading Panel at runtime. I am
not that experienced in VB.
Thanks
Class MyClass
Inherits UserControl
Private WithEvents _MyParentPanel As Panel
Private Sub PChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.ParentChanged
Me._MyParentPanel = CType(sender, Control).Parent
end sub
Private Sub ParentScrollChange(ByVal sender As Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles _MyParentPanel.Scroll
' Handle change
End Sub
End Class
-- modified 27-Mar-19 11:48am.
|
|
|
|
|
What happens if Parent is not a Panel ?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Yeah, there's lots of problems with it.
We'll start with your assumption that the control will over ever be dropped on a Panel control. What if you accidentally drop it on a Form instead? You're code is going to throw an exception and the designer is going to show a problem that prevents rendering it and you'll probably freak out when that happens.
A control can have many different control types as a parent. Change the references "Panel" to "Control" so you can support different container controls, including a Form since the Form class derives from Control.
It's also not a good idea to rename your event handlers, specifically PChanged , to whatever is shorter. It make the code harder to read and understand without your eyes darting to the end of each line to figure out which event this method handles. Your name is also not descriptive at all. What's a "P" and what changes about it?
|
|
|
|
|
To All,
Sorry for not providing enough information. I was focused on the implementation
of whether Me._MyParentPanel = CType(sender,Control).Parent had any underlying issues
as far as 'attaching' the control to the Panels Scroll event because of loading
_MyParentPanel at runtime.
I understand and agree with the issues you raised but:
This control is for a specific application and will not be dropped onto the Panel or be
used for any other purpose.
It is created by a button click from the Panel and is added by the Panel onto the Panel.
Thanks
|
|
|
|
|
speedbump99 wrote: This control is for a specific application and will not be dropped onto the Panel or be
used for any other purpose.
Famous last words. Controls always start out that way, but then next year, "Hey! We've got this control we want to use somewhere else..."
Do it right the first time.
|
|
|
|
|
Thanks Dave,
This app is for my personal use only and I am 'infinitely' sure that this
control will never, ever, ever be used anywhere else. But I do appreciate
your input.
Best regards.
|
|
|
|
|
Hello !
I'm using entity framework 6 with sql server 2008r2.
I have a bindingsource :
Mybindingsource.datasource=(From t in context.myobjects order by t.name select t).ToList
Now , I want to search inside the bindingsource , and get the found item's index.
I'm using this code :
Function findindex(startposition as integer) As integer
Dim p as Myobject
Dim i as integer
For i=startposition to Mybindingsource.count-1
p=MyBindingsource.item(i)
if p.value=3 then return i
Next
return 0
End Function
This code is working , but when the bindingsource contains too many itmes , is very slow.
Is there any faster way ?
Thank you !
modified 26-Mar-19 21:13pm.
|
|
|
|
|
desanti wrote: This code is working , but when the bindingsource contains too many itmes , is very slow.
Is there any faster way ? Yes, select by primary key instead of an index.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Sorry , I need to get the index of found item in bindingsource.
|
|
|
|
|
Than you will have to deal with a slow bindingsource.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hi ,
How to change db path from local to server? I just couldn't figure out the right syntax.
\\server01
Public Function ConnectDataBase() As System.Data.OleDb.OleDbConnection
strPathData = MyPath(Application.StartupPath) & "Data\"
strPathImages = MyPath(Application.StartupPath) & "Images\"
Dim strConn As String = _
"Provider = Microsoft.ACE.OLEDB.12.0;"
strConn +=
"Data Source = " & strPathData & "Contact.accdb"
Conn = New OleDb.OleDbConnection(strConn)
' Create Connection
Conn.ConnectionString = strConn
' Return
Return Conn
End Function
modified 25-Mar-19 15:58pm.
|
|
|
|
|
RedPandinus wrote: Application.StartupPath Inspect the content of this variable and then
RedPandinus wrote: strPathData value, it will give you the idea.
Use a UNC path when you replace the values as not all clients will have the drive mapped to the same letter.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
Hi,
How can I search and find records including special or standart characters both at database?
For instance, When I search for word "ğşçişüö" code should find "ğşçişüö" and also "gsısuo".
or vice versa.
|
|
|
|
|
When you store the string in the database, have a second column which stores the string with the accents removed.
When you search, remove the accents from the search string, and search the column without the accents.
How do I remove diacritics (accents) from a string in .NET? - Stack Overflow[^]
Public Shared Function RemoveDiacritics(ByVal text As String) As String
Dim normalizedString As String = text.Normalize(NormalizationForm.FormD)
Dim stringBuilder As New StringBuilder()
For Each c As Char In normalizedString
Dim unicodeCategory As UnicodeCategory = CharUnicodeInfo.GetUnicodeCategory(c)
If unicodeCategory <> UnicodeCategory.NonSpacingMark Then
stringBuilder.Append(c)
End If
Next
Return stringBuilder.ToString().Normalize(NormalizationForm.FormC)
End Function
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard you have a Dim statement inside the loop, is there a performance/elegance issue with continually declaring a new variable. I always declare the variables at the start of the method and try never to declare within a loop structure.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
Moving the variable declaration out of the loop produces exactly the same IL, so it won't make any difference to the performance.
I generally prefer to declare variables where they're needed. Since the unicodeCategory variable isn't used outside of the loop, and the value doesn't need to persist between iterations, I think it makes sense to declare it within the loop.
There's some discussion of this on StackOverflow:
.net - Faster to declare variables inside a loop or outside a loop? - Stack Overflow[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Alternatively, look into SoundEx.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
|
Hi,
How to export Access database to Excel with a button click in a VB project? Thank you.
modified 19-Mar-19 7:38am.
|
|
|
|
|