|
Yes, if you databind to your control, the selection is lost. I suspect you are databinding again when the selectio nchanges.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks for the suggestion, I just looked into that and it is not hitting the databind code again after the initial databind until the correct place.
One thing I just noticed as a pattern. If I have 15 items in a listbox and I try to scroll through them it goes in this type of order.
1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, 9, etc...
Does that ring any bells?
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
|
|
|
|
|
No, that does sound strange. It sounds like your data source is messed up ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I think I explained that incorrectly, when I said that it goes in the order of 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, etc... I mean that the selected index will work that way, the highlighted item. So there will be a total of say 15 items in the box but when I scroll through the highlighted item will be the first item, second item, third item, fourth item, fifth item, back to the first item then through the sixth and back to the first again.
Here is the code I use to load the listboxes.
<br />
uxDepartments.DataSource = Nothing<br />
uxDepartments.Items.Clear()<br />
uxDepartments.SelectedIndex = -1<br />
<br />
_DepartmentTable = New DataTable<br />
<br />
_DepartmentTable = GetDepartmentNames<br />
<br />
uxDepartments.DataSource = _DepartmentTable<br />
uxDepartments.ValueMember = "DepartmentNameID"<br />
uxDepartments.DisplayMember = "DepartmentName"<br />
<br />
'Need to clear the listboxes with multi selection enabled<br />
uxDepartmentsForList.SelectedItems.Clear()<br />
<br />
If _DepartmentTable.Rows.Count = 2 Then<br />
uxDepartmentsForList.SelectedIndex = 1<br />
Else<br />
uxDepartmentsForList.SelectedIndex = -1<br />
End If<br />
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
|
|
|
|
|
CleaKO wrote: _DepartmentTable = New DataTable
This is obviously a waste of time, but it won't cause your issue.
And this is a winforms app, and this code does not run again ? What's your selected index changed look like ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Christian Graus wrote: This is obviously a waste of time, but it won't cause your issue.
Yes I am a little off and on with the new object setting depending on how I set the object later. I believe this was written before I quit with the extra step.
<br />
If uxDepartments.SelectedIndex > 0 Then<br />
uxDepartmentEdit.Text = CType(uxDepartments.SelectedItem, DataRowView)("DepartmentName").ToString.Trim<br />
uxAddDepartmentName.Enabled = False<br />
uxUpdateDepartmentName.Enabled = True<br />
uxDeleteDepartmentName.Enabled = True<br />
<br />
Else<br />
uxDepartmentEdit.Text = ""<br />
uxAddDepartmentName.Enabled = True<br />
uxUpdateDepartmentName.Enabled = False<br />
uxDeleteDepartmentName.Enabled = False<br />
<br />
End If<br />
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
|
|
|
|
|
Hi,
I have put in a custom Context menu in the webbrowser control for VB 2005. I am using the following to find out which item was clicked on:
in the document complete event:
oDoc = wBrowser.Document 'Odoc is a System.Windows.Forms.HtmlDocument
Private Sub oDoc_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.HtmlElementEventArgs) Handles oDoc.MouseDown
'Here is it's an input element? if yes we want to show the normal windows options....
If e.MouseButtonsPressed = Windows.Forms.MouseButtons.Right And oElement.TagName = "INPUT" Then
wBrowser.IsWebBrowserContextMenuEnabled = True
Else
wBrowser.IsWebBrowserContextMenuEnabled = False
End If
Dim MPoint As New Point(e.MousePosition.X, e.MousePosition.Y)
oElement = wBrowser.Document.GetElementFromPoint(MPoint)
End Sub
Private Sub oDoc_MouseMove(ByVal sender As Object, _
ByVal e As System.Windows.Forms.HtmlElementEventArgs) Handles oDoc.MouseMove
' On Error Resume Next
Dim MPoint As New Point(e.MousePosition.X, e.MousePosition.Y)
'e.MousePosition.X, e.MousePosition.Y)
oElement = oDoc.GetElementFromPoint(MPoint)
end sub
Private Sub cmRightClick_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles cmRightClick.Opening
If Not IsNothing(oElement) Then
If oElement.TagName = "IMG" Then
imageMenu.Enabled = True
Else
imageMenu.Enabled = False
End If
If oElement.TagName = "A" Then
linkMenu.Enabled = True
Else
linkMenu.Enabled = False
End If
End If
The code works fine in some cases but in others (such as a facebook profile page), if I click on the profile image, the OElement tagname is "Body" and neither of "IMG" or "A". Any Ideas? thanks
|
|
|
|
|
Hi,
I am getting the this error :Object Reference not set to an instance.
when i debug i came to know that 'qry' is not initialized.Bui have initialized it.Don't Know why 'qry' is not getting initialized.
my code is:
Dim rdoSex As String
Dim CreateDate As String
Dim qry as String
Dim i As Integer
CreateDate = Now.Date.ToString()
If rdoMale.Checked = True Then
rdoSex = "M"
ElseIf rdoFemale.Checked = True Then
rdoSex = "F"
Else
rdoSex = "NA"
End If
Try
qry = ""
qry = "insert into T_STU_MASTER values('" &CreateDate & "','" & txtStudentName.Text.Trim() & "','" & txtFatherName.Text.Trim() & "','" & txtMotherName.Text.Trim() & "','" & rdoSex & "','" & dtpDOB.Text.Trim() & "','" & cmbVillage.SelectedItem.ToString().Trim() & "')"
cmd = New SqlCommand(qry, con)
'//Error is thrown in above line that qry is null while i have initialized it
i = cmd.ExecuteNonQuery()
If i > 0 Then
MsgBox("Information Saved Successfully!!!")
End If
Catch ex As Exception
MsgBox(ex.ToString())
Finally
con.Close()
End Try
|
|
|
|
|
As far as I can see, that's not possible.
Are you absolutely certain that it's not the con variable that isn't initialised?
devsheoran wrote: Urgent Please help
It's never urgent enough to mention in the subject.
Despite everything, the person most likely to be fooling you next is yourself.
modified on Tuesday, March 11, 2008 4:39 PM
|
|
|
|
|
Are you *certain* ? Although this is pretty terrible code, I don't see any way that qry could be uninitialised. Try stepping through with the debugger and checking variable values, I think it's con that is null, it's the only thing I can not see initialisation code for.
You need to read this[^]. You also need not to initialise variables over and over ( you set qry to "", then in the next line, change it ). Also, rdoSex is not a radio button. Hungarian notation is not generally used nowadays anyhow, but that's just wrong.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
can somebody help me. i made a project that compose of many forms., in the 2nd form, it has timer that has only 30 min. and it will stop if 30 minutes is over. But if the 30 minutes is not yet over and i already reach the last form which is form10, the timer in the 2nd form should stop and the 2nd form will be hide. How can i do it?
the project that i am making is an IQ test, and it has many pages, when the test is answered already, the timer should stop..
can somebody please help me about my problem.. thanks!
|
|
|
|
|
You end up with 10 forms visible ? Sounds like you really want a wizard type interface.
Use delegates to get form10 to tell form2 that the timer is no longer required, and to make that form hide.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
no, the other forms will not be visible. the only visible form is the 2nd form, the form that has timer.
how to use delegates? can you tell me the codes for it?
|
|
|
|
|
I don't understand completely:
If all of these forms are in the same application then why don't you have form10 call form2's timer
and tell it to stop.
|
|
|
|
|
I am using the create user wizzard on my asp.net page. Can i specify which database users are added to and can i give users the ablilty to update details. can any one help me please.
Many thanks
|
|
|
|
|
This is better asked on the ASP.NET forum.
I have no idea, I don't use any of the built in wizards, I write my own code.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
hi all,
How would one go about replacing a character in a string with a space where the character is not in the range of a-z or A-Z or 0-9 ???
the following Code did not have the planned outcome...
Dim cleanString As String = [String].Empty<br />
Dim reg As New Text.RegularExpressions.Regex("[A-Z]|[a-z]|[0-9]")<br />
Dim coll As Text.RegularExpressions.MatchCollection = reg.Matches(LineText, )<br />
For i As Integer = 0 To LineText.Length - 1<br />
MsgBox(coll(i).Value)<br />
If (coll(i).Value = [String].Empty) Then<br />
cleanString = cleanString + " "<br />
Else<br />
cleanString = cleanString + coll(i).Value<br />
End If<br />
Next
the result was not pritty.... it removed spaces as well... how do i keep spaces and replace (NOT REMOVE) other characters with a space???
Thank you in advance.
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Try using the Regex.Replace[^] function.
Scott.
—In just two days, tomorrow will be yesterday.
—Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines] [ Articles] [ Blog]
|
|
|
|
|
With a single line of code:
Dim cleanString = Regex.Replace(LineText, "[^A-Za-z\d ]", " ")
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
If e.KeyCode = Keys.F1 Then
'MsgBox("F1 pressed")
AxWindowsMediaPlayer1.URL = "E:\iva_megh\audio\welcome.wav"
Play()
Do While AxWindowsMediaPlayer1.status <> "Stopped" And Timer1.Enabled And Not bInterrupted
Application.DoEvents()
Loop
End If
Sorry do not know how to continue the thread. Please inform me.
Thank you for all the efforts!
|
|
|
|
|
meghanaVishwa wrote: Sorry do not know how to continue the thread. Please inform me.
When viewing the message you want to reply to, simply click the "reply" link and write the new message. It will automatically be appended to the thread with the appropriate indenting level based on the message to which you were replying.
Scott.
—In just two days, tomorrow will be yesterday.
—Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines] [ Articles] [ Blog]
|
|
|
|
|
meghanaVishwa wrote: Do While AxWindowsMediaPlayer1.status <> "Stopped" And Timer1.Enabled And Not bInterrupted
Application.DoEvents()
Why is this not a complete waste of code ? I don't see what it could possible achieve?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
i have written it but the control is not going there when i debug it
|
|
|
|
|
yeah, great. why don't you use the thread you already started?
what did you write?
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|
|
Hi,
I beleive this sample code is in C#:
string cleanString = String.Empty;<br />
Regex reg = new Regex("[A-Z]|[a-z]");<br />
MatchCollection coll = reg.Matches(<mystringgoeshere>);<br />
for(int i = 0; i < coll.Count; i++)<br />
{<br />
cleanString = cleanString + coll[i].Value;<br />
}</mystringgoeshere>
See, i want to remove all characters that do not fall in the A-Z or a-z OR 0-9 category AND replace it with a space...
example test123t3er = test t er
Am i wrong in saying that the Regex reg = Regex("[A-Z]|[a-z]") CAN IT BE: Regex reg = Regex("[A-Z]|[a-z]|[0-9]") ???
AND the cleanString = cleanString + coll[i].Value;
CAN I DO A TEST: IF(coll[i].Value == String.Empty) THEN cleanString = cleanString + " " ELSE cleanString = cleanString + coll[i].Value ???? - in this way i add space if the character is not in the above category????
So please help me convert the very top section of code and i will build from there...
Thank you in advance...
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|