|
Need to create a combo box dynimcally in a datagrid? How can this be done? How to make the combo box invisible when scrolled to the header & above in the datagrid table?
hz
|
|
|
|
|
I copied the following code from this board and it doesn't work!
<
Module Module2
Delegate Function EnumWindows_Callback(ByVal hWnd As Integer, ByVal lParam As Integer) As Integer
Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As EnumWindows_Callback, ByVal lParam As Integer) As Integer
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Integer, ByVal lpString As String, ByVal cch As Integer) As Integer
'The callback routine.
Function EnumWindows_CBK(ByVal hWnd As Integer, ByVal lParam As Integer) As Integer
Dim buf As String
Dim i, length As Long
' Get the window's title.
length = GetWindowText(hWnd, buf, 255)
Title = Microsoft.VisualBasic.Left(buf, length)
' See if the title contains the target.
i = InStr(1, Title, "Table")
If i > 1 Then
' Save the hwnd and end the enumeration.
g_TableHwnd = hWnd
Return 0
Else
' Continue the enumeration.
Return 1
End If
End Function
End Module
Private Sub doScreen_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ptr As Integer
ptr = 0
' Examine the window names.
g_TableHwnd = 0
EnumWindows(AddressOf EnumWindows_CBK, ptr)
If g_TableHwnd = 0 Then
MsgBox("Error finding table.")
Exit Sub
End If
'Activate table.
ActivateTable()
GetTablePosition()
ThisValue = 0
potnum = 0
cardnum = 0
stacknum = 0
' Take back the focus.
Me.Activate()
End Sub
>
I only need the handle of the application with the word "table" in its caption so I removed a few things from the original code but not anything which should have effect the the ability of the code to loop through the active applications and return thier handles as emumWindows does in my vb6 code. This code is identical to my vb6 code except for the delegate and call back functions.
What happens id that "hWnd", which is passed to the <enumwindows_cbk> function is not "0" when it gets there from the form load sub. Instead it is some 6 digit number and on each iteration it becomes some other 5 or 6 digit number. It should start at 0 and work up one at a time.
I really need this function to work. My whole project is hung up on it.
Can anybody help?
Thanks
Dick Roose
|
|
|
|
|
dick roose wrote:
What happens id that "hWnd", which is passed to the function is not "0" when it gets there from the form load sub. Instead it is some 6 digit number and on each iteration it becomes some other 5 or 6 digit number. It should start at 0 and work up one at a time.
You seem totally lost. That's what happen when you copy code without knowing what it does. A HWND is a number that signifies a window on the system, it does not run from 0 onwards, but is correctly represented by the numbers you are getting.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I need a calculator for VB.net that is small and only uses the keyboard for entering calculations and does not show buttons and has a tape form. Is this possible? Does anyone have one or code somewhere?
|
|
|
|
|
Yes it is possible. No I don;t have code. Try Googling it, you may find a hit or two.
...Steve
|
|
|
|
|
|
I know this isn't hard but as of late I've suffered a massive brainfart.
I'm populating a datagrid from a dataset, and I want to count the number of times each string appears in either of them (whichever is easier) and return that count to a label. However, I have to do this for all unique strings in the grid, and there is no definite number of strings to check against.
For example, the datagrid and the dataset it's populated with will look something like this:
ID | NAME
----------------------
1 | Bob
2 | Bob
3 | Joe
4 | Mary
5 | Joe
And I want the output (to be put into a label) to look like this:
Total Rows: 5
Bob occured: 2 times
Joe occured: 2 times
Mary occured: 1 time
And like I said, I will not only be checking for just Joe, Bob, and Mary, so hard-coding the strings I'm looking for isn't going to work.
Thanks in advance for any help.
-------------------
abort, retry, fail?
|
|
|
|
|
My SQL is limited at best, but I'm sure there's a way you can count occurances in the dataset. I know that ""SELECT DISTINCT " & psFieldName & " FROM " & sTable" will produce 1 result for each unique field name so there should be some variation of this that could give you a count. Sorry I can't be of more help.
|
|
|
|
|
I'll play around with that and see what I can do. I was looking for along the lines of iterating throught the result set after it's been fetched, but I suppose SQL can work, too.
-------------------
abort, retry, fail?
|
|
|
|
|
If you query it directly on the database something like the following should do the job:
SELECT NAME, COUNT(ID) FROM TableName GROUP BY NAME
If this is not possible something like this should do the job:
Dim hash As Hashtable
For Each row As DataRow In dataTable.Rows
Dim name As String = row("NAME").ToString()
If hash.ContainsKey(name) Then
hash.Add(name, 1)
Else
hash(name) = Convert.ToInt16(hash(name)) + 1
End If
Next
Dim result As String = ""
For Each name As String In hash.Keys
result = name & " occured: " & hash(name).tostring() & " times"
Next
|
|
|
|
|
thanks for your input. getting close, but now quite there - I've never used hash tables before, so I'm not sure how to handle this error:
Item has already been added. Key in dictionary: "TEST NAME" Key being added: "TEST NAME"
<br />
Line 72: Dim name As String = row("TLH_1_317").ToString()<br />
Line 73: If hash.ContainsKey(name) Then<br />
<font color="red">Line 74: hash.Add(name, 1)</font><br />
Line 75: Else<br />
Line 76: hash(name) = Convert.ToInt16(hash(name)) + 1<br />
your thoughts?
-------------------
abort, retry, fail?
-- modified at 12:09 Monday 10th October, 2005
|
|
|
|
|
all i had to do was change the
If hash.ContainsKey(name) Then
to
If Not hash.ContainsKey(name) Then
Thanks!
-------------------
abort, retry, fail?
|
|
|
|
|
Sh*t happens when quickly coding something out of the head
|
|
|
|
|
I have a popup menu handler. How do I figure out (preferrably the index) of the actual menu item selected?
Public Sub MyHandler(ByVal sender As System.Object, ByVal e As System.EventArgs)
' Need to know the index of the item selected here...
end sub
|
|
|
|
|
There is no "index" property per se, you can create a select and evalute the name of the sender:
Select Case Sender.Name
Case "lblSlot1"
end select
Or you could set the Tag property of each label to your index value then take the value of the tag:
piIndex = Val(Sender.Tag)
Those are my two best ideas anyway
|
|
|
|
|
Richard,
Thanks, for the idea but what I am refering to is did they select menu item #1, Menu items #2 and so-on.
I am sure these is a simple way, just have not seen it in the MS documentation yet...
Mike
|
|
|
|
|
The answer remains the same, the "sender" object is what was clicked. Evaluate the name you gave the menu item or set it's Tag property and look at that.
|
|
|
|
|
Each menu item can have methods that are triggered upon selection. If I have a popup menu (aka context menu) with three items: "One", "Two" and "Three" and I select menu item "Two" from the menu then my program will receive a "Two_Clicked()" event. You need to trap that event in your program and then (possibly) call your own generic handler from that event. That way you always know which item was selected.
...Steve
|
|
|
|
|
I have a handler for a context menu
Public Sub MyHandler(ByVal sender As System.Object, ByVal e As System.EventArgs)
|
|
|
|
|
hello everyone,
i would like to code an application that can simply answer a call using the modem and log which keys (or in other words which dtmf commands are sent) are pressed. it's something i have never worked into so i am in need of help. through several web sites i've checked into this but the results i got (sample codes or articles) were not satisfactory. so if someone could feed me a sample that can simply log the buttons pressed by the caller or an address of an idiotproof article that would be useful i would be really grateful cause i simply couldn't figure out where to start. can there be a basic method of processing such commands from a modem, non-dependent of the chipset or does it have to vary with every different model?
thanks
|
|
|
|
|
This is done through TAPI (Telephony API). The problem is that not all modems support this and there is no standard classes in the .NET Framework that wrap TAPI. You have to use a third party library the supports this. The problem here is that not a libraries completely wrap the TAPI API's. There are also multiple versions of TAPI, each with it's own feature set that it supports.
THe bottom line is that there is no "idiotproof" article that explains al this. The topic is just too broad. You'll have to do a bunch of reasearch on the support you need, then find a library that wraps the sections of the TAPI API that you need, and, hopefully, that library will come with documentation on how to use it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
What is work with this?
If Me.txtClientId.Text = "" Then
Me.CheckBox1.Value = False ' unchecked
Else
Me.CheckBox1.Value = True ' checked
End If
|
|
|
|
|
There's nothing wrong with the code itself, where the code is may be of more relevance. If this code is in your checkbox1 click event it may generate an infinite loop. More information on which language you're using and the type of problem or the type of solution you're needing would be helpful
Note: For VB6 the .Value property is not a boolean as the option button is, it may be one of three values: vbChecked, vbUnchecked or vbGrayed.
|
|
|
|
|
I wanted to import an info. from Excel (worksheet.range("A40"), for example. Let say, if this cell is blank, a check box remains unchecked. If this cell contains something, I want a check box to be checked. Thank you so much.
|
|
|
|
|
Assuming that an empty cell is the same as "" then change your " = True" to " = vbChecked" and your " = False" to " = vbUnchecked".
|
|
|
|