|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to implement ComboBox.FindValueHow do I implement the value equivalent of the ComboBox.FindStringExact
method? I.e. How do I set the ComboBox.SelectedIndex so that the ComboBox.SelectedValue object matches one that I specify. Thanks in advance for any help, Hal Heinrich VP Technology Aralan Solutions Inc. Hal,
When I had not read your answer to Dennis I would have given the same answer as he. Therefore it is true that probably Dennis did not understand your question, probably because of the way the question was asked. The answer is simple, use a dataview (or defaultview) as datasource and use a dataview.find to find the rowindex. That you can set to your selectedindex. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadataviewclassfindtopic1.asp I hope this helps? Cor Cor,
Thanks for your reply. I'd like to rephrase the question as follows: Can you provide an implementation for the following function definition? Public Function FindValue(ByVal cb As System.Windows.Forms.ComboBox, ByVal obj As Object) As Integer 'Parameters ' cb ' the ComboBox to be searched ' obj ' the Object to search for ' 'Return Value ' The zero-based index of the first item found; returns -1 if no match is found. ' 'Remarks ' Uses the Equals method of the Object class to determine a match ' returns the index for which the following is true: ' obj.Equals(cb.SelectedItem) ' End Function Thanks, Hal Show quoteHide quote "Cor Ligthert" wrote: > Hal, > > When I had not read your answer to Dennis I would have given the same answer > as he. > > Therefore it is true that probably Dennis did not understand your question, > probably because of the way the question was asked. > > The answer is simple, use a dataview (or defaultview) as datasource and use > a dataview.find to find the rowindex. That you can set to your > selectedindex. > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadataviewclassfindtopic1.asp > > I hope this helps? > > Cor > > > if cb.items.contains(obj) then
return cb.items.indexOf( obj) else return -1 end if Does this work for you ? http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformscomboboxobjectcollectionclassindexoftopic.asp HTH rawCoder Show quoteHide quote "Hal Heinrich" <HalHeinr***@discussions.microsoft.com> wrote in message http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadataviewclassfindtopic1.aspnews:8A320415-75B8-4214-80ED-E4EC78464C4E@microsoft.com... > Cor, > > Thanks for your reply. I'd like to rephrase the question as follows: > > Can you provide an implementation for the following function definition? > > Public Function FindValue(ByVal cb As System.Windows.Forms.ComboBox, > ByVal obj As Object) As Integer > 'Parameters > ' cb > ' the ComboBox to be searched > ' obj > ' the Object to search for > ' > 'Return Value > ' The zero-based index of the first item found; returns -1 if no > match is found. > ' > 'Remarks > ' Uses the Equals method of the Object class to determine a match > ' returns the index for which the following is true: > ' obj.Equals(cb.SelectedItem) > ' > End Function > > Thanks, > Hal > > "Cor Ligthert" wrote: > > > Hal, > > > > When I had not read your answer to Dennis I would have given the same answer > > as he. > > > > Therefore it is true that probably Dennis did not understand your question, > > probably because of the way the question was asked. > > > > The answer is simple, use a dataview (or defaultview) as datasource and use > > a dataview.find to find the rowindex. That you can set to your > > selectedindex. > > > > Show quoteHide quote > > > > I hope this helps? > > > > Cor > > > > > > Thank you!
That is exactly what I was after. Hal Show quoteHide quote "rawCoder" wrote: > if cb.items.contains(obj) then > return cb.items.indexOf( obj) > else > return -1 > end if > > Does this work for you ? > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformscomboboxobjectcollectionclassindexoftopic.asp > > HTH > rawCoder > > "Hal Heinrich" <HalHeinr***@discussions.microsoft.com> wrote in message > news:8A320415-75B8-4214-80ED-E4EC78464C4E@microsoft.com... > > Cor, > > > > Thanks for your reply. I'd like to rephrase the question as follows: > > > > Can you provide an implementation for the following function definition? > > > > Public Function FindValue(ByVal cb As System.Windows.Forms.ComboBox, > > ByVal obj As Object) As Integer > > 'Parameters > > ' cb > > ' the ComboBox to be searched > > ' obj > > ' the Object to search for > > ' > > 'Return Value > > ' The zero-based index of the first item found; returns -1 if no > > match is found. > > ' > > 'Remarks > > ' Uses the Equals method of the Object class to determine a > match > > ' returns the index for which the following is true: > > ' obj.Equals(cb.SelectedItem) > > ' > > End Function > > > > Thanks, > > Hal > > > > "Cor Ligthert" wrote: > > > > > Hal, > > > > > > When I had not read your answer to Dennis I would have given the same > answer > > > as he. > > > > > > Therefore it is true that probably Dennis did not understand your > question, > > > probably because of the way the question was asked. > > > > > > The answer is simple, use a dataview (or defaultview) as datasource and > use > > > a dataview.find to find the rowindex. That you can set to your > > > selectedindex. > > > > > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadataviewclassfindtopic1.asp > > > > > > I hope this helps? > > > > > > Cor > > > > > > > > > > > >
Anyone tried REALbasic?
ArrayList Strongly Typed VB6 easier than VB.NET? Datagrid colum sorting problem - URGENT HELP! Cannot start NEW project Windows Form DataGrid - Need A Color Border Around Only The Selected Row - Will GDI Be Required vb.net dll Button in a datagrid (windows form) Can forms be imported from MS Access? Cobol to .Net |
|||||||||||||||||||||||