|
Don't think you can get more efficient than that. Unless you do some loop unrolling...
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi!
I am populating the treeview on fly from database. I am trying to maintain the selected state of a tree node (either parent or child). select node in parent works fine but when i try to find a child node i get null reference exception. can someone please tell me how i could select the child node.
thanks
|
|
|
|
|
uglyeyes wrote: select node in parent works fine but when i try to find a child node i get null reference exception. can someone please tell me how i could select the child node.
Have you set breakpoints in your code, and then looked at data in your objects? This will do wonders, it will let you see if the data in your objects/variables are what you were expecting. Without more detail, such as what you tried, detailed expection info, or some code, that's the best I can offer. I left my crystal ball at home.
I'm going to become rich when I create a device that allows me to punch people in the face over the internet.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
|
|
|
|
|
yes i did set up breakpoint.
If Not Session("locationid") Is Nothing Then --> when they select a node i am storing the value of selected node in session
Debug.WriteLine(Session("locationid"))
'Debug.WriteLine(tvProperty.SelectedNode.Value)--> prints value of the node
tn = Me.tvProperty.FindNode(Session("locationid"))--> where i get null ref exception
tn.Selected = True
End If
please note it didnt throw exception when i navigate between parent nodes.
its only happening when i navigate between child nodes.
in findnode do i need to give ref of parent, path seperator etc?
|
|
|
|
|
can anyone please help me?
|
|
|
|
|
i posted too early without doing any research. i should have used valuepath in session instead of just value to get the selected child node selected.
|
|
|
|
|
My question is this...
I am trying to change a column of a datagrid to a drop down combo box. I set everything up but my problem is that I am displaying a list of text in my combobox ("Preparer", "Reviewer", "Approver") I need to set the values of these items to 1, 2, 3. I don't want the program to recognize the string representation of the items but their enumerated values. How do I achieve this?
|
|
|
|
|
Every item in the datagrid will have fields as Text and value.
Generally Text and value are taken as the same, but user can change value field to any thing without effecting data in the text field.
Check datagrid properties...
Jats
|
|
|
|
|
How can I have the text of the selected Item from listivew by enter key?
Using vb.net 2005
Thanks In advance
|
|
|
|
|
insert a keydown-event for your listview.
then check e.keys for enter-key and when enter is pressed, pick out your listview's selected item and convert it to a string. then you have your selected item's text.
|
|
|
|
|
Hi,
I have 2 forms.On main form I have a listview and a button to add the customer in the listview.
On clicking the add customers button a new form opens up with a gridview with all the customers.Now what I want is that when user select multiple customers from the gridview and click ok button on customers list form then the selected customers from gridview should be added in the listview.
Thanks in advance
|
|
|
|
|
How about this:
<br />
dim v as integer<br />
For v = 0 To DataGridView1.SelectedCells.Count - 1<br />
ListView1.Items.Add(DataGridView1.SelectedCells(v).Value)<br />
Next v<br />
Good Luck.
|
|
|
|
|
I am working in VB.NET. I have a probelm regarding changing the System/Computer TimeZone from the VB.NET code. Is it possible with VB.NET code and how can we do this?
Thanks
Azmat Ullah
|
|
|
|
|
Me.OracleInsertCommand1.Parameters.AddRange(New System.Data.OracleClient.OracleParameter() {New System.Data.OracleClient.OracleParameter(":ADDBY", System.Data.OracleClient.OracleType.VarChar, 30, "ADDBY"),etc...
I'm using VS 2005 and it says AddRange doesn't belong the ParametersCollection.
But this is generated code from VS! (possibly 2003, we upgraded)
Can someone with 2003 check if it was valid in that version?
"Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."
"There is no one who loves pain itself, who seeks after it and wants to have it, simply because it is pain..."
|
|
|
|
|
Me.OleDbInsertCommand1.Parameters.AddRange is a valid method apparently.
So the problem could be with the Oracle library?
"Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."
"There is no one who loves pain itself, who seeks after it and wants to have it, simply because it is pain..."
|
|
|
|
|
I want to display a webpage on a windows form. And gradually i want to iterate and display several webpages on it. Also i need to do something when a particular webpage completes download to the window.
Can anybody please advise how can i achieve this using windows forms in vb.net 2005. I used WebBrowser control but it doesn't allows me to specify a url address through coding, but if I set the URL property to a site address at design time then it displays the site when the form loads.
Thanks in Advance. Please Help.
Sekhar
|
|
|
|
|
SekharOne wrote: I used WebBrowser control but it doesn't allows me to specify a url address through coding
Yes it does, try :-
WebBrowser1.Url = New System.Uri("http://www.google.co.uk")
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
Thanks Steven
that worked.
Thanks a lot once again. You people are simply Great.
Sekhar
|
|
|
|
|
Is there is any way to format textbox for numeric values without using databinding?
Thanks In advance
Ejaz
|
|
|
|
|
Create a new class called NumericBox and inherit Windows.Forms.TextBox
Now all you need to do is intercept keypresses with the KeyPress event, and validate them, for example :-
Private Sub NumericBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress<br />
Dim KeyAscii As Integer<br />
<br />
KeyAscii = Asc(e.KeyChar)<br />
<br />
Select Case KeyAscii<br />
Case 8, 13 ' backspace and carriage return<br />
'Do nothing as the input is valid<br />
Case 48 To 57 ' Keys 0 to 9 <br />
'Test the number of decimal places<br />
If Me.Text.Contains(".") Then<br />
If (Me.Text.Trim.Length - InStr(Me.Text, ".")) >= DecimalPlaces Then KeyAscii = 0<br />
End If<br />
<br />
'Test to see if the new value will exceed the maximum value<br />
'or minimum value limits<br />
Dim sValue As String = Value.ToString<br />
Dim dValue As String<br />
sValue &= e.KeyChar<br />
dValue = CType(sValue, Decimal)<br />
If dValue < Minimum Or dValue > Maximum Then KeyAscii = 0<br />
<br />
'Do nothing as the input is valid<br />
Case 45 'minus sign<br />
If AllowNegativeValues Then<br />
'If negative values as permitted then...<br />
If Me.Text.Contains("-") Then<br />
'if we already have a minus sign then throw away this minus sign keystroke just pressed<br />
KeyAscii = 0<br />
End If<br />
<br />
If Me.SelectionStart <> 0 Then<br />
'If the insertion point is not sitting at zero (the beginning of the field),<br />
'throw away the minus sign<br />
KeyAscii = 0<br />
End If<br />
Else<br />
KeyAscii = 0<br />
End If<br />
<br />
Case 46 'decimal point<br />
If AllowDecimalPoint Then<br />
If Me.Text.Contains(".") Then<br />
KeyAscii = 0<br />
End If<br />
Else<br />
KeyAscii = 0<br />
End If<br />
<br />
Case Else<br />
'Any other input is invalid so throw it away<br />
KeyAscii = 0<br />
End Select<br />
<br />
If KeyAscii = 0 Then<br />
Beep()<br />
e.Handled = True<br />
Else<br />
e.Handled = False<br />
End If<br />
<br />
End Sub
The snippet above utilises additional properties I have added to my NumericBox, should as AllowNegativeValues and AllowDecimalPoints both of which are Boolean values
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
This works unless the user is allowed to paste into the textbox...
If you're rolling your own numeric textbox, then you have to look at the TextChanged event and validate the contents on every change.
Everyone's first thought is to handle the keys pressed, but you'd be suprised how many users paste into textbox's.
David Anton
http://www.tangiblesoftwaresolutions.com
C++ to C# Converter
C++ to VB Converter
C++ to Java Converter
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++ VB Edition: VB to C++/CLI converter
Instant C++ C# Edition: C# to C++/CLI converter
|
|
|
|
|
|
Hii ,
Here i am creating all controls at runtime i.e, (Textbox,Chkbox,Rb,GridView,Picturebox,Label...... ,RectangleShape,OvalShape,LineShape).
How to implement Cut ,Copy ,Paste,Delete for all these types of controls ....
1) Here i am using ContextMenuStrip .--------------Using this how to delete , in that i am having Properties ,Cut,Copy,Paste,Delete,SendToBack,BringToFront
If i select, delete or copy or paste or cut it has to do the respective operations for the type of control listed above.How to identify the control.
i am getting the sender here as "ToolStripMenuItem" , How can i get the particular Control .
How can i identify the Control here ?????
2) if i press the delete button on keyboard , i am doing this
Ctr_KeyDown -- event handler <br />
<br />
If e.KeyCode = Keys.Delete Then<br />
<br />
If TypeOf sender Is TextBox Then<br />
<br />
Canvas.Controls.Remove(Sender) ........
But i am not able to delete the Picturebox ,& shape controls(due to it accepts only Control )
Thanks
For1206
|
|
|
|
|
I have this code for sending email but it gives me an error...plz help
my code:
Dim email As New System.Net.Mail.MailMessage
Dim credentials As New System.Net.NetworkCredential
Dim f As New MailAddress(from)
Dim t As New MailAddress(receipient)
Dim smtp As New SmtpClient
With credentials
.Domain = "www.gmail.com"
.UserName = "prubyholl"
.Password = "mypassword"
End With
With email
.From = f
.To.Add(t)
.Subject = subject
.Body = body
End With
With smtp
.Host = server 'contains the smtp server correctly
.Port = "587"
.EnableSsl = True
.Credentials = credentials
.Send(email)
End With
the error:
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required h19sm6066249wxd.28
Plz help
phatkin
|
|
|
|
|
Dim smtpClient As SmtpClient
Dim message As MailMessage
Dim fromAddress As MailAddress
smtpClient = New SmtpClient()
message = New MailMessage()
fromAddress = New MailAddress("From Address") ' Mention your from address
smtpClient.Host = "Your SMTP Host"
' Give your SMTP host address as mail.company.com, specify the host name or ipaddress of your server
'Default port will be 25
smtpClient.Port = 25
'From address will be given as a MailAddress Object
message.From = fromAddress
' To address collection of MailAddress
message.To.Add("To Address") ' Give your To Address
message.Subject = "Subject"
' Message body content
message.IsBodyHtml = True
message.Body = "Body Part"
' Send SMTP mail
smtpClient.Send(message)
Hi check this code, i used this long back. So if there are any small errors fix it. But it will work.
I think you have forgot to mention the SMTP Host, I mean Host IP address at the place of .Host = Server
Jats
|
|
|
|