|
|||||||
|
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Hyperactive Member
Join Date: Feb 07
Location: Omnipresence
Posts: 477
![]() |
I have a form that has a large number of labels. Is there a way I can move the focus from label to label. After I move the focus I'll check if the name of the label has a certain string in it. If it does then I'll leave the focus at that label. If it doesn't I'll move the focus to the next label and check if that label name has the string in it. I just need to know how to move the focus from label to label. I was trying SelectNextControl without success. Maybe I can tab programmatically to the next label but I don't know how to do that.
__________________
Make as many mistakes as you can as quickly as you can. We want to make sure that we make a great enough number of mistakes in a given amount of time so that we can be successful.![]() "Persistence is the magic of success." Paramahansa Yogananda |
|
|
|
|
|
#2 |
|
ASP.Nut
Join Date: Nov 04
Location: The Granite City
Posts: 14,451
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: Want to check all labels on form to see if Label name has certain string within i
Hey,
Have you seen jm's post here: http://www.vbforums.com/showthread.php?t=387308 I think this might help you. Check each control to see if it is a Label, and if it is, do the check that you need. Hope that helps!! Gary
__________________
Remember to mark your thread as resolved. Check out the new Forum features, including tagging here. Remember to rate posts that help. My Site - ASP.Net Website running on CentOS 5.3 with Mono My Blog - Blog on Aberdeen Developers .Net User Group View my MCP Certifications Free Stuff: WebsiteSpark|DreamSpark|BizSpark Learning Resources: MSDN|LearnVisualStudio|TrainingSpot|ScottGu's Blog|ASP.Net Starter Kits|Regex|RegExLib Useful Tools: XPath Builder|UltraMon|RegExBuddy|CopySourceAsHtml|TracExplorer|SQLyog|Chart Controls for .Net|SharePoint Designer|CodeRush Express Coding Links: XPath|ConnectionStrings|VB and MySQL|MySQL Connector.Net|My.Settings ADO.Net: MSDN Reference|Introduction|Using Access|Always use Parameters|Save and Retrieve Data - jm|An Explanation - jm Code Bank Submissions: Code Snippets|Profile Provider|Serialization: C# VB|Restricted Menu|Compressed HttpWebRequest|Enumerate and Add Internet Explorer Favourites: VB C#|C# Tabbed Web Browser|Enhanced Tabbed Web Browser: VB C# |
|
|
|
|
|
#3 | |
|
PowerPoster
Join Date: May 07
Location: Chelmsford UK
Posts: 8,268
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: Want to check all labels on form to see if Label name has certain string within i
try this:
vb Code:
__________________
if this helps, rate me irregular regions | numericTextbox | keycodes | removing control properties | hotkeys | rtf printing | Extended RichTextBox | iconWorks | readonly listbox | sort listview | screen capture | relational listForms | countDown timer | animated notifyIcon form | dynamic crystal report | move / resize runtime controls | reOrderable DnD listview / listbox | self closing message box | searchable list(of class) | cursor from bitmap | (VB2008+) Textbox - GetFirstVisibleLineIndex / GetLastVisibleLineIndex | vb2008 extensions | Paint lite.Net | calculator | inline calculator | export listview to word table | imperial~metric converter | export DGV to word ~ excel Quote:
|
|
|
|
|
|
|
#4 |
|
Frenzied Member
Join Date: Sep 06
Location: Corner of the Europe :)
Posts: 1,735
![]() ![]() |
Re: Want to check all labels on form to see if Label name has certain string within i
You cant select labels with selectnextcontrol...
You can do something like: vb.net Code:
__________________
Rate People That Helped You![]() Mark Thread Resolved When Resolved |
|
|
|
|
|
#5 |
|
ASP.Nut
Join Date: Nov 04
Location: The Granite City
Posts: 14,451
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: Want to check all labels on form to see if Label name has certain string within i
Hey,
Am I not right in saying that to use each of the above approaches, you would also need to recurse into each control to see whether it had additional child controls? i.e. if there is a Panel on the form. That is why I suggested jm's approach, as this recursion is not needed. Gary
__________________
Remember to mark your thread as resolved. Check out the new Forum features, including tagging here. Remember to rate posts that help. My Site - ASP.Net Website running on CentOS 5.3 with Mono My Blog - Blog on Aberdeen Developers .Net User Group View my MCP Certifications Free Stuff: WebsiteSpark|DreamSpark|BizSpark Learning Resources: MSDN|LearnVisualStudio|TrainingSpot|ScottGu's Blog|ASP.Net Starter Kits|Regex|RegExLib Useful Tools: XPath Builder|UltraMon|RegExBuddy|CopySourceAsHtml|TracExplorer|SQLyog|Chart Controls for .Net|SharePoint Designer|CodeRush Express Coding Links: XPath|ConnectionStrings|VB and MySQL|MySQL Connector.Net|My.Settings ADO.Net: MSDN Reference|Introduction|Using Access|Always use Parameters|Save and Retrieve Data - jm|An Explanation - jm Code Bank Submissions: Code Snippets|Profile Provider|Serialization: C# VB|Restricted Menu|Compressed HttpWebRequest|Enumerate and Add Internet Explorer Favourites: VB C#|C# Tabbed Web Browser|Enhanced Tabbed Web Browser: VB C# |
|
|
|
|
|
#6 |
|
Hyperactive Member
Join Date: Feb 07
Location: Omnipresence
Posts: 477
![]() |
Re: Want to check all labels on form to see if Label name has certain string within i
Thanks for the help. .paul your code works perfectly. Perfectly that is the first time but for some reason if I close the form and change the string to something else and then reopen the form it goes to the first result every time. I tried setting ctrl = nothing before closing the form but it doesn't change anything. Not sure why. I'm putting the code in the form load sub.
I've checked to see that the string is changing and it is but once the form opens at a certain position going to the correct label it keeps on opening at the same position even though the string is changing to something that is found in some other label name for that form. I looked at jmc's code and I get the same problem using his method. I tried setting the focus to the first label on the form before running the code but it doesn't fix the problem.
__________________
Make as many mistakes as you can as quickly as you can. We want to make sure that we make a great enough number of mistakes in a given amount of time so that we can be successful.![]() "Persistence is the magic of success." Paramahansa Yogananda |
|
|
|
|
|
#7 | |
|
PowerPoster
Join Date: May 07
Location: Chelmsford UK
Posts: 8,268
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: Want to check all labels on form to see if Label name has certain string within i
delete your binaries + rebuild
thats your bin/debug folder
__________________
if this helps, rate me irregular regions | numericTextbox | keycodes | removing control properties | hotkeys | rtf printing | Extended RichTextBox | iconWorks | readonly listbox | sort listview | screen capture | relational listForms | countDown timer | animated notifyIcon form | dynamic crystal report | move / resize runtime controls | reOrderable DnD listview / listbox | self closing message box | searchable list(of class) | cursor from bitmap | (VB2008+) Textbox - GetFirstVisibleLineIndex / GetLastVisibleLineIndex | vb2008 extensions | Paint lite.Net | calculator | inline calculator | export listview to word table | imperial~metric converter | export DGV to word ~ excel Quote:
|
|
|
|
|
|
|
#8 | |
|
PowerPoster
Join Date: May 07
Location: Chelmsford UK
Posts: 8,268
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: Want to check all labels on form to see if Label name has certain string within i
if that didn't work...
what are the names of the 2 controls + what are you searching for?
__________________
if this helps, rate me irregular regions | numericTextbox | keycodes | removing control properties | hotkeys | rtf printing | Extended RichTextBox | iconWorks | readonly listbox | sort listview | screen capture | relational listForms | countDown timer | animated notifyIcon form | dynamic crystal report | move / resize runtime controls | reOrderable DnD listview / listbox | self closing message box | searchable list(of class) | cursor from bitmap | (VB2008+) Textbox - GetFirstVisibleLineIndex / GetLastVisibleLineIndex | vb2008 extensions | Paint lite.Net | calculator | inline calculator | export listview to word table | imperial~metric converter | export DGV to word ~ excel Quote:
|
|
|
|
|
|
|
#9 |
|
Hyperactive Member
Join Date: Feb 07
Location: Omnipresence
Posts: 477
![]() |
Re: Want to check all labels on form to see if Label name has certain string within i
OK. I tried deleting both the bin and obj(has debug folder in it) folders and did a rebuild and the problem is still there.
On a particular first trial the string st5 = "Dph". I open the form with all the labels and it goes to LabelDph just like it should. I close the form and click in a different combobox ComboBoxBph. st5 = "Bph" now since I use : Code:
st5 = Me.ActiveControl.Name
st5 = st5.Replace("ComboBox", "")
I used st6 to see what ctrl.Name is and it's LabelDph in the first case and LabelBph in the second case even though the form is opening at the LabelDph position in both cases. Code:
For Each ctrl In Me.Controls
ctrl.Focus()
If ctrl.Name.Contains(st5) Then
st6 = ctrl.Name
Exit For
End If
Next
If I click in ComboBoxBph first and then open the form with all the labels then it will open at LabelBph. If I then closed the form clicked in ComboBoxDph and then opened the form it would open at LabelBph again. It always gets the first opening of the form right and it always keeps the same position at all openings of the form after that until I close my application and start it up again.
__________________
Make as many mistakes as you can as quickly as you can. We want to make sure that we make a great enough number of mistakes in a given amount of time so that we can be successful.![]() "Persistence is the magic of success." Paramahansa Yogananda Last edited by EntityX; Dec 19th, 2009 at 11:56 AM. |
|
|
|
|
|
#10 |
|
Hyperactive Member
Join Date: Feb 07
Location: Omnipresence
Posts: 477
![]() |
Re: Want to check all labels on form to see if Label name has certain string within i
I created a new project from scratch. Made it very simple. 2 labels on the form that opens and I had the same problem even when using different code. I tried using Me.AutoScrollPosition = New Point(0, 1100) and Me.AutoScrollPosition = New Point(0, 0). And it would again open at the proper position the first time but would keep opening at the same position after that. I traced it to using Form2.ShowDialog()instead of using Form2.Show(). If I use Show instead of ShowDialog then the problem disappears. Thanks for your help everyone.
__________________
Make as many mistakes as you can as quickly as you can. We want to make sure that we make a great enough number of mistakes in a given amount of time so that we can be successful.![]() "Persistence is the magic of success." Paramahansa Yogananda |
|
|
|
|
|
#11 |
|
Frenzied Member
Join Date: Sep 06
Location: Corner of the Europe :)
Posts: 1,735
![]() ![]() |
Re: Want to check all labels on form to see if Label name has certain string within i
I'm a little bit confused...
You're trying to change the label names at runtime, and expect the second time you open the form the name it's the new one? When you say close the form, you say close the application?
__________________
Rate People That Helped You![]() Mark Thread Resolved When Resolved |
|
|
|
|
|
#12 | |
|
PowerPoster
Join Date: May 07
Location: Chelmsford UK
Posts: 8,268
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: Want to check all labels on form to see if Label name has certain string within i
try changing this:
vb Code:
to: vb Code:
__________________
if this helps, rate me irregular regions | numericTextbox | keycodes | removing control properties | hotkeys | rtf printing | Extended RichTextBox | iconWorks | readonly listbox | sort listview | screen capture | relational listForms | countDown timer | animated notifyIcon form | dynamic crystal report | move / resize runtime controls | reOrderable DnD listview / listbox | self closing message box | searchable list(of class) | cursor from bitmap | (VB2008+) Textbox - GetFirstVisibleLineIndex / GetLastVisibleLineIndex | vb2008 extensions | Paint lite.Net | calculator | inline calculator | export listview to word table | imperial~metric converter | export DGV to word ~ excel Quote:
|
|
|
|
|
|
|
#13 |
|
Hyperactive Member
Join Date: Feb 07
Location: Omnipresence
Posts: 477
![]() |
Re: Want to check all labels on form to see if Label name has certain string within i
An explanation for mickey pt :
The second form in my large application was a form to explain the settings that are seen on a form that has numerous ComboBoxes. So I have ComboBoxBph and ComboBoxDph, etc, etc, on one form and then you click a button Explain Settings and another form opens with explanations of the settings that you change with the ComboBoxes. So LabelBph on form ExplainSettings would explain setting Bph which is alterred using ComboBoxBph which is on the first form and not on the form that has the explanations.
__________________
Make as many mistakes as you can as quickly as you can. We want to make sure that we make a great enough number of mistakes in a given amount of time so that we can be successful.![]() "Persistence is the magic of success." Paramahansa Yogananda |
|
|
|
![]() |
|
||||||
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|