|
You have to handle the DrawItem event of the ComboBox:
DrawItemEventArgs[^]
The example is for a ListBox, but the theory is exactly the same.
Hope this helps
Tom
|
|
|
|
|
thanks tom.
i'm beginner in vb.net and in the sample i don't understant where put the code...
please help me.
thanks
wilson
|
|
|
|
|
Hi all,
Can anybody let me know how to change the column name of datagrid.
It displays the same name as per in table.
I want to change it.
let Emp_Code is the column name in table and I want the column name as Employee Code to be displayed.
Please help.
Suman Singh
|
|
|
|
|
It is possible through SQL query. Use 'ALias' command of sql.
example
select 'FirstName'=au_fname,'LastName'=au_lname from authors
use this query, hope you understand it.
au_fname and au_lname are column names, where as 'First Name' and 'Last Name' are fake names.
bye
EsHbAn BaHaDuR
|
|
|
|
|
I attach a text box on form. user has to enter date in that text box. How can i set the format mask for date like dd:mm:yyyy
EsHbAn BaHaDuR
|
|
|
|
|
The standard TextBox control doesn't support masked editing. You have to use the old ActiveX MaskedEdit control for this. A reference for which you can find here[^] on MSDN.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Here's instruction for including the control in your project: [^]
Are you familiar with the MaskedEdit control in VB6? It's just about the same. If you aren't familiar, then you can Google it or look further on vbcity.com, just remember you are looking for VB6 instructions, not VB.NET.
|
|
|
|
|
I want to select some data from database and display it in DATAGRID control, how can i use it without using "Data Adapter" and "DataSET" objects
EsHbAn BaHaDuR
|
|
|
|
|
I don't think you can do it without the two, if you are using database.
Please wait for another reply.
|
|
|
|
|
How else are you going to get the data out of the database?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am a new learner of VB.net.
Can anybody let me know, how to call a buton_click procedure on textbox.keypress event.
Suman Singh
suman9730@hotmail.com
|
|
|
|
|
place the following line of code into your keypress event handler:
me.myButton.PerformClick()
-jim
|
|
|
|
|
Hi,
Thanks for your quick reply.
But how can I identify the button if i have 5 buttons on the form.
Please help again.
A learner this side.
Thanks!
|
|
|
|
|
is it a situation where you want to perform a click on a particular button based on which text box has the focus?
if this is the case, just evaluate what you want to determine and perform a click on the appropriate button. for instance
Private Sub myKeyPressHandler(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles myTextBox.KeyPress,
someOtherTextBox.KeyPress,
yetAnotherTextBox.KeyPress
If (Object.ReferenceEquals(sender, Me.myTextBox)) Then
me.myButton.PerformClick()
elsif (object.ReferenceEquals(sender, me.someOtherTextBox))
me.someOtherButton.PerformClick()
elseif (object.ReferenceEquals(sender, me.yetAnotherButton))
me.yetAnotherButton.PerformClick()
else
messagebox.show("It was yet even another textbox that received the text!")
End If
End Sub hope this helps you out.
-jim
|
|
|
|
|
Thanks again Jim,
I want to press Enter key in textbox after giving my password (let say)
And by pressing Enter key, the code written in
Private sub Login_Validate_button(by val sender as object......)handles....
----
----
----
End Sub
get invoked.
How can I call this button procedure by pressing the Enter key in textbox.
Thanks !
|
|
|
|
|
no problem Suman,
in this case, just handle the keypress as follows...
private sub txtPassword_KeyPress(byval sender as object, byval e as System.windows.forms.keyeventargs) handles txtPassword.KeyPress
if (e.keycode=keys.enter) then
me.btnLogin.PerformClick()
end if
End Sub when working with event handlers, always look to the event arguments for context specific data regarding the event being raised.
-jim
|
|
|
|
|
i need to loop some rows in my datagrid to add them and show the total.
i am using:
<br />
Dim dr As DataRow<br />
Dim Amount As Double = 0<br />
For Each dr As System.Data.DataRow _<br />
In ds.Tables(0)<br />
dr = dr + ds.Tables(0).Rows.Item("Amount")<br />
Next<br />
Me.Text = ("My Balance $") & Amount.ToString<br />
everything is fine except the underlined part. it keeps saying that it is a member of system.data.datatable which is not a collection type. does anyone know what i am doing wrong?
Makniteasy
|
|
|
|
|
Tables(0) is not a collection, it's a specific table.
...
For each r as Datarow in ds.Tables(0).Rows
... by the way your initial declaration of dr is reduntant since you are initializing it again within your for statement. just thought i'd mention it.
-jim
|
|
|
|
|
thanks that fixed that problem but now i have another:
<br />
Dim Amount As Double = 0<br />
<br />
For Each dr As DataRow In ds.Tables(0).Rows<br />
<br />
dr = dr + ds.Tables(0).item("Amount")<br />
<br />
Next<br />
Me.Text = ("My Balance $") & ("Amount").ToString<br />
now this is underlined. i think im lost in the loop now.any more suggestions?
Makniteasy
|
|
|
|
|
can you give us an idea of exactly what it is you're trying to do? the code you've provided doesn't really make much sense.
just a brief description should help.
-jim
|
|
|
|
|
You're not adding the amounts. You're actually trying to add a Column to a DataRow.
I think you're looking for:
Dim Amount As Double = 0
For Each dr As DataRow In ds.Tables(0).Rows
Amount += dr.Item("Amount")
Next
Me.Text = "My Balance $" & Amount.ToString()
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
thanks for the help. The help you provided was exactly what i needed. i was trying to get the amount column of a datagrid, for which the user enters the amount they paid, to show in the datagrid caption text when entered.
I am going to post another question so that you wont have to keep to returning this one.
thanks
Makniteasy
|
|
|
|
|
I'm having another issue with my little HTA application that I'm hoping you could advise on.
Basically when a user enters a PC name in a box and selects GO. I want the code to run a ping against the remote machine to see if it is online or not. Now in a normal vb script the IsConnectible ping check works great. However when called from within my HTA app it always come back and says that the PC is online.
Anyone know why its not working in the HTA?
This is my code...thanks
<title>System Information
<hta:application
="" id="objSysInfo" applicationname="System Information" scroll="yes" singleinstance="yes" windowstate="maximize">
Sub MainSub
On Error Resume Next
DataArea.InnerHTML= " "
sComputer = ComputerTextBox.Value
If sComputer = Empty Then
strHTML = strHTML & "Please Enter a Computer Name "
DataArea.InnerHTML = strHTML
Else
If IsConnectible(sComputer,"","") Then
strHTML = strHTML & "Computer is online"
Else
strHTML = strHTML & "Computer is offline"
End If
DataArea.InnerHTML = strHTML
End If
End Sub
Sub IsConnectible(sHost, iPings, iTO)
' Returns True or False based on the output from ping.exe
'
' Author: Alex Angelopoulos/Torgeir Bakken
' Works an "all" WSH versions
' sHost is a hostname or IP
' iPings is number of ping attempts
' iTO is timeout in milliseconds
' if values are set to "", then defaults below used
If iPings = "" Then iPings = 2
If iTO = "" Then iTO = 750
Const OpenAsDefault = -2
Const FailIfNotExist = 0
Const ForReading = 1
Set oShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
sTemp = oShell.ExpandEnvironmentStrings("%TEMP%")
sTempFile = sTemp & "\runresult.tmp"
oShell.Run "%comspec% /c ping -n " & iPings & " -w " & iTO _
& " " & sHost & ">" & sTempFile, 0 , True
Set fFile = oFSO.OpenTextFile(sTempFile, ForReading, _
FailIfNotExist, OpenAsDefault)
sResults = fFile.ReadAll
fFile.Close
oFSO.DeleteFile(sTempFile)
IsConnectible = CBool(InStr(sResults, "TTL="))
End Sub
|
|
|
|
|
You might want to check the contents of your Temp file that PING write first, before you delete it. I think the answer to your question will be in there.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Can someone PLEASE look at the following code??
<code>
<Serializable()> _
Public Class SerialDataPack
Public Shared PLCname As String '-- PLC Station name
Public Shared Reason As Reasons '-- Enumerate of reason to send
Public Shared File() As Byte '-- File as bytearray
Enum Reasons
[STARTUP]
[EVENT]
[REQ]
[GENREQ]
End Enum
End Class</code>
i serialize the object, send it to the other client and do the following code:
<code>Dim filepath As String = "c:\PLC\Listener\Received\Temp " & EventCounter & ".bin"
'-- write this file to HDD location filepath;
Dim BW As New BinaryWriter(File.OpenWrite(filepath))
BW.Write(Buffer, 0, numbytes)
BW.Close()
'-- then read it back with binaryformatter
Dim bf As BinaryFormatter = New BinaryFormatter
Dim fs = New FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.Read)
Dim SocketListenerSDRecv As SerialData.SerialDataPack
'-- similair to CType but faster runtime according to MSDN
SocketListenerSDRecv = DirectCast(bf.Deserialize(fs), SerialData.SerialDataPack)
fs.Close()</code>
when i DESERIALIZE the fs i get the folowing error (and CType spawns same error);
"The given conversion is invalid"
does someone has a suggestion, maybe i should re-implement my serializable class?????
If you make something idiotproof, someone else will make a better idiot.....
|
|
|
|