473,385 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Refresh of control (color)

Me.tvKunder.ForeColor = Color.FromArgb(l)
changes the color of the Treeview control 'tvKunder' immidiately.

Using a loop:
For Each c In Me.Controls
If (TypeOf c Is ListBox) Or (TypeOf c Is TreeView) Then
c.BackColor = Color.FromArgb(l)
c.Refresh()
End If
Next
...won't change the color before restart of application?

I tried refreshing the control in the For-Next and the entire form
outside the For-Next. Didn't help either.
Regards /Snedker
Nov 21 '05 #1
4 2104


Morten Snedker wrote:
Me.tvKunder.ForeColor = Color.FromArgb(l)
changes the color of the Treeview control 'tvKunder' immidiately.

Using a loop:
For Each c In Me.Controls
If (TypeOf c Is ListBox) Or (TypeOf c Is TreeView) Then
c.BackColor = Color.FromArgb(l)
c.Refresh()
End If
Next
..won't change the color before restart of application?

I tried refreshing the control in the For-Next and the entire form
outside the For-Next. Didn't help either.


Your example code isn't actually setting the BackColor of any TreeView
- is your treeview on a panel maybe? When I explicitly set a treeview's
BackColor I see immediate results (and in fact an exception is thrown
if you try to give a treeview a transparent BackColor).

Remember that unlike the VB6 Controls collection, for a VB.NET Form,
Controls only includes the 'top-level' controls (ie not stuff *in a
container control* on the form).

--
Larry Lard
Replies to group please

Nov 21 '05 #2
On 17 Jun 2005 06:13:34 -0700, "Larry Lard" <la*******@hotmail.com>
wrote:
That may be it. The treeview actually is on a panel. Should I then
reference the treeview through the panel?
Your example code isn't actually setting the BackColor of any TreeView
- is your treeview on a panel maybe? Remember that unlike the VB6 Controls collection, for a VB.NET Form,
Controls only includes the 'top-level' controls (ie not stuff *in a
container control* on the form).

Nov 21 '05 #3

Yes, if you know in advance that's where it is then you can find it by
looping through Me.MyPanel.Controls.

In general if you want to iterate over all controls on a form , you
need a recursive solution like this:

'to call do this from somewhere in the form:
IterateControls(Me.Controls)

'this is the recursive proc
Sub IterateControls(cs As ControlCollection)
Dim cIter As Control
For Each cIter In cs
ProcessControl cIter
IterateControls cIter.Controls 'recurse down the hirerachy
Next
End Sub

'this is the processing routine that does whatever to a single control
Sub ProcessControl(c As Control)
'for example:
If TypeOf c Is Treeview Then
c.BackColor = Color.Red
End If
End Sub
Morten Snedker wrote:
On 17 Jun 2005 06:13:34 -0700, "Larry Lard" <la*******@hotmail.com>
wrote:
That may be it. The treeview actually is on a panel. Should I then
reference the treeview through the panel?
Your example code isn't actually setting the BackColor of any TreeView
- is your treeview on a panel maybe?

Remember that unlike the VB6 Controls collection, for a VB.NET Form,
Controls only includes the 'top-level' controls (ie not stuff *in a
container control* on the form).


Nov 21 '05 #4
On 17 Jun 2005 07:17:28 -0700, "Larry Lard" <la*******@hotmail.com>
wrote:

Thank you. Your help is greatly appreciated! :-)

Regards /Snedker
Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Scott | last post by:
I have a clickable graph that resides on page 1. If user clicks a data point on the graph, the page runs again yeilding a 2nd graph that shows a more detailed graph. Problem is, I have a...
6
by: Arnold | last post by:
Hey there, I've browsed for some fixes to this but only found a couple of similar posts, which didn't solve my problem. I'm wondering how to refresh an image control in a form after a user...
4
by: Yogi_Bear_79 | last post by:
Self Taught here so please bear with me. I have the labelRestrictSites as private on the MainForm.cs. I then access the labelRestrictSites.Text thru the public string LabelRestrictSites from...
2
by: Peter Oliphant | last post by:
I now have graphics being drawn in the Paint event of my form (yeah, and it's very cool). Problem was that it only updated any changes to these graphics when Paint was called. So, I then made it...
3
by: Prince | last post by:
How can I refresh a page from the code behind pages? I know Server.Transfer("<same page>") works. However, I am refreshing a page from a Button within a user control which has it's own code...
1
by: ppatel | last post by:
Problem I have a problem with web image button control click event. The click event does not get trigger until it has not been clicked once or page refresh occures(which is fine). When click...
3
by: MyWebTV | last post by:
how to refresh an indiviual user control without refresh entrire page
17
by: SamSpade | last post by:
picDocument is a picturebox When I do picDocument.Invalidate() the box paints. But if instead I do picDocument.Refresh() the box does not paint. What does Refresh do. I guessed it did an...
0
by: Allan Bredahl | last post by:
Hi all Im currently constructing a Windows control that inherits from RichTextBox, but I'm having a bit of trouble with updating the control at design time. The senario is SIMPLIFIED as...
3
by: R.A.F. | last post by:
Hi, I have a custom control in which i have a property based on CollectionBase class. like the following one : //------- XGrid.cs file --------------// public ColumnsCollection Columns {
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.