|
Thanks for that. Will give it a tryout asap but that code con vertor link just says "Thanks! We're now processing your upload" for ever.
|
|
|
|
|
Hi,
The first method only sets up a grid, and hooks up the paint-event. The second method would roughly translate to the code below;
Shared ReadOnly rectSize As New Size(10, 10)
Private Shared Sub dgv_CellPainting(sender As Object, e As DataGridViewCellPaintingEventArgs)
e.Handled = False
If 0 = e.ColumnIndex Then
If -1 = e.RowIndex Then
Return
End If
e.PaintBackground(e.CellBounds, DataGridViewElementStates.Selected = e.State)
e.PaintContent(e.ClipBounds)
e.Graphics.FillRectangle(Brushes.Red, New Rectangle(e.CellBounds.Location, rectSize))
e.Handled = True
End If
End Sub
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Wow, thank you! That is mighty impressive With a bit of fiddling i got the required triangle shape.
[code]
e.Handled = False
If 0 = e.ColumnIndex Then
If -1 = e.RowIndex Then
Return
End If
e.PaintBackground(e.CellBounds, DataGridViewElementStates.Selected = e.State)
e.PaintContent(e.ClipBounds)
Dim x1 As Integer = e.CellBounds.Right
Dim y1 As Integer = e.CellBounds.Top
Dim x2 As Integer = x1 - 7
Dim y2 As Integer = y1
Dim y3 As Integer = y1 + 7
Dim x3 As Integer = x1
e.Graphics.FillPolygon(Brushes.Red, {New Point(x1, y1), New Point(x2, y2), New Point(x3, y3)})
e.Handled = True
End If
[/code]
However 2 things to ask please. How do is set which column the shape is in and when clicked
the text forecolor changes to white (until released). Can that forecolor not change ?
|
|
|
|
|
You're welcome
Helium99 wrote: How do is set which column the shape is in The event-handler is executed for each cell; we check in the handler whether we're in the first column, and if so, then paint. That's done by the line below;
If 0 = e.ColumnIndex Then Would have been more readable if it said "If e.ColumnIndex = 0 Then". Change the 0 to a 1 to have it appear in the second column.
Helium99 wrote: when clicked the text forecolor changes to white (until released). Can that
forecolor not change That might be the "highlight" color that has been set, but I'm not sure.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
This code is working properly
DataEnvironment1.Commands("Command1 ").CommandType = adCmdText
DataEnvironment1.Commands("Command1 ").CommandText = "Select * from TenderBlocksCalcolations where ProjectsCode = '" & txtProjectCode.Text & "'"
But when i make grouping its not works
DataEnvironment1.Commands("Command1_Grouping").CommandType = adCmdText
DataEnvironment1.Commands("Command1_Grouping").CommandText = "Select * from TenderBlocksCalcolations where ProjectsCode = '" & txtProjectCode.Text & "'"
Can you give any idea?
|
|
|
|
|
Yeah, you don't have any GROUP BY clause in your SQL statement.
You might want to read up on it here[^].
|
|
|
|
|
My purpose is to identify a specific USB device which, once installed via its driver, will go under the COM Port devices, appearing with a speficic name and a specific GUID Class ID will be defined for it as well.
If I want to access this device, is there a way for detecting which COM port has been assigned by Windows? If yes, it would be possible to automatically attach to it without asking the user to check and then select the right COM port.
SepPax
modified 16-May-15 11:52am.
|
|
|
|
|
|
The example you posted will return the COM Port names (COM1, COM2, COMx...).
My need is different.
Assume to have a USB device named "USB Dev" connected to COM7.
What I want to achieve is finding out on which COM port the device 'USB Dev' is connected, therefor locate it via its name.
Possible?
SepPax
modified 13-May-15 18:38pm.
|
|
|
|
|
Use the suggestion, write the code, report the results.
Then, if it doesn't work, ask for further assistance.
|
|
|
|
|
Works well with name search
Dim port as string
Dim device as string
Try
Using searcher As New ManagementObjectSearcher("root\CIMV2", "SELECT * FROM Win32_SerialPort")
For Each queryObj As ManagementObject In searcher.Get()
port = queryObj("DeviceID")
device = queryObj("Description")
Next
End Using
Catch err As ManagementException
MessageBox.Show("An error occurred while querying for WMI data: " & err.Message)
End Try
check device for what you look for.
SepPax
|
|
|
|
|
I have code to select a specific cell in a DataGridView control:
With dgvPlanAssemblies
.ClearSelection()
.CurrentCell = .CurrentRow.Cells("RoughPriceOverrideCol")
End With
The selection does indeed move to the correct cell. The problem is that the focus does not move. I have tried to use the .Selected = True method and BeginEdit:
With dgvPlanAssemblies
.ClearSelection()
.CurrentCell = .CurrentRow.Cells("RoughPriceOverrideCol")
.CurrentRow.Cells("RoughPriceOverrideCol").Selected = True
.BeginEdit(True) ' Also tried False '
End With
Nothing I tried method moves the focus to the selected cell.
Any help is appreciated.
|
|
|
|
|
Hi guys,
does anybody have a good and proven serial data receive routine (example) to share with me?
My data are structured as following:
[start of frame][frame length][data....][end of frame]
Everything is HEX bytes, so guess can't use string reading.
Basically need a buffer where to look for the start, wait for the frame to be received til its end, process the frame and remove the processed part of buffer from the remaining buffer.
Any help and hint is welcome.
SepPax
|
|
|
|
|
|
useful, something more advanced to suggest?
SepPax
|
|
|
|
|
Did you take a look at these Codeproject articles[^]?
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Not yet, but will. Thanks for the lead
SepPax
|
|
|
|
|
SepPax wrote: something more advanced to suggest? Yes, learn to make an effort to do your own research. Google will find you plenty of samples and articles.
|
|
|
|
|
hmmm, greatly appreciate your help...your suggestion tells me a lot.
Checking the forum, for me at least, is sometimes the way for optimizing the development time, of course, when people are willing to share their experience with others, allowing those others to take advantake of their skill, their trial and error, their optimizing etc.
When people are not willing to share, well, then of course there is a huge amount of things out there you can reach via BigG.
Nothing personal, but why should people spend time on feeding and maintaining specific and specialized forum(s), if the final goal is fooling around with Google?
Cheers.
SepPax
|
|
|
|
|
Look at the question you asked:
SepPax wrote: something more advanced to suggest? So what are we to guess from that? How much more advanced, what level of experience do you have that we can respond to ... ? As you see it's an impossible question to answer. I suggest you read http://www.codeproject.com/Messages/1278601/How-to-get-an-answer-to-your-question.aspx[^]. Only by thinking carefully about exactly what problem you are facing, and providing a clear explanation, can we begin to think of ways to help you.
|
|
|
|
|
Well Richard,
can't say you are wrong... will try my best to improve
SepPax
|
|
|
|
|
Hi guys,
getting crazy about this issue, can't figure out the reason. I'm sure that a more skilled eye than mine can get the point, any help is welcome.
I get the below error (see end of the code).
Basically I have a decoding function feeded with a key (pbKey), an input array (pbIn) and an output array (pBout).
Don't understand what VB is asking for...
Seppax
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim k As Byte() = {&H1F, &H33, &H52, &H59, &H02, &H04, &H77, &H67, &H13, &H0E, &H00, &H15, &H15, &H02, &H0F}
Dim dat As Byte() = {&H5F, &H4F, &HDA, &HA3, &H97, &H14, &H81, &HB1}
Dim s, a As String
Dim out As Byte()
TeaD(k, dat, out)
End Sub
Private Function TeaD(ByVal pbKey() As [Byte], ByVal pbIn() As [Byte], ByVal pbOut() As [Byte]) As Byte()
Dim i As [Byte] = New [Byte]()
Dim y As UInteger
Dim z As UInteger
Dim sum As UInteger = &HC6EF3720UI
Dim delta As UInteger = &H553569AAUI
Dim n As UInteger = 32
Dim k(4) As UInteger
y = pbIn(2)
z = pbIn(6)
k(0) = pbKey(2)
k(1) = pbKey(6)
k(2) = pbKey(10)
k(3) = pbKey(14)
For i = 0 To 2
y <<= 8
z <<= 8
k(0) <<= 8
k(1) <<= 8
k(2) <<= 8
k(3) <<= 8
y = y Or pbIn(2 - i)
z = z Or pbIn(6 - i)
k(0) = k(0) Or pbKey(2 - i)
k(1) = k(1) Or pbKey(6 - i)
k(2) = k(2) Or pbKey(10 - i)
k(3) = k(3) Or pbKey(14 - i)
Next i
Do While n > 0
z -= ((y << 4) Xor (y >> 5)) + y Xor (sum + k(sum >> 11 And 3))
sum -= delta
y -= ((z << 4) Xor (z >> 5)) + z Xor (sum + k(sum And 3))
n = n - 1
Loop
For i = 0 To 3
pbOut(i) = y
pbOut(i + 4) = z
y >>= 8
z >>= 8
Next i
End Function
|
|
|
|
|
You didn't initialize your byte-array-variable out(), resp. pbOut(). You just declared it in Button1_Click(..). Looks like you want to want to write to its indices 0 to 7, so you would have to initialize it like so:
Dim out As Byte() = New Byte(7) {}
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Many thanks Sascha!
From your answer I understand that by doing so I need to fix the dimension on the array.
From the original purpose, pbIn() and pBout() could have variable length...would there be a way to handle this?
SepPax
|
|
|
|
|
SepPax wrote: From your answer I understand that by doing so I need to fix the dimension on the array. Well, you need to initialize the variable for the array with an instance of an array. Array-variables are references and declaring them (e.g. Dim out As Byte() ) only yields a null-array-reference (or 'Nothing'-array-reference) that can but not yet has been assigned an actual array.
The 'dimension' is a different thing: You have declared a one-dimensional array here and there's (probably) nothing wrong with that. You might want to take a look at the MSDN page talking about arrays:
https://msdn.microsoft.com/en-us/library/wak0wfyt.aspx[^]
SepPax wrote: From the original purpose, pbIn() and pBout() could have variable length...would there be a way to handle this? That's the trouble with arrays: If you don't know beforehand how 'large' they have to be it get's a bit ugly, because they can't dynamically grow. Of course you could deal with that yourself but it's much more convenient to use a suitable collection-class then which will handle this for you. I guess a generic list would make sense in your case:
Dim out As New List(Of Byte)()
Please refer: List<T>[^]
SepPax wrote: Many thanks Sascha! You're welcome!
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|