[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

FLabel Part VI

Posted on 2009-02-14
10
Medium Priority
?
341 Views
Last Modified: 2012-05-06
This time I would like to indicate some columns are inactive in the stack of usercontrols. My thought was to simply use DrawLine to draw an X over the column. However, everything I have tried draws the X under the usercontrols instead of on top.

The only way I got it to draw on top was to use ControlPaint.DrawReversibleLine, but I need thicker lines and that is not changable.

I also tried adding pictureboxes and locating them over the columns, but they also appear under the usercontrols.

How can I place an indicator on top of the usercontrols?

Thanks.
0
Comment
Question by:LeeLiam
  • 5
  • 5
10 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 23643431
...this time I recommend you use the Paint() event again instead of trying to paint "over" them...  ;)

So you'll need to store the fact that some columns are inactive and then in the Paint() event draw an "x" over those spots.
0
 

Author Comment

by:LeeLiam
ID: 23645448
I have a subroutine that determines the inactive columns and calls another subroutine that draws the X. The usercontrols are on a panel. I've tried calling the first subroutine from the Panel_Paint and from the Form_Paint and nothing appears. If I call it from the uc_MouseMove, the X appears under the user control.

It may be a problem with the way I'm using DrawLine. My code for that is shown below. Should I modify it?

Thanks.
    Private Sub MyDrawLine(ByVal p1 As Point, ByVal p2 As Point)
        p1 = Me.PointToScreen(p1)
        p2 = Me.PointToScreen(p2)
        Dim g As Graphics = Graphics.FromHwnd(Panel.Handle)
        Dim myPen As Pen = New Pen(Color.Red, 6)
        g.DrawLine(myPen, p1, p2)
    End Sub

Open in new window

0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 23645616
"Graphics.FromHwnd" is a TEMPORARY graphics and will be erased whenever the control "underneath" is refreshed...an event that you have no control over.  This is why I suggested you draw the inactive columns "x"s in the Paint() event to make them persistent.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:LeeLiam
ID: 23645689
I'm assuming I do that with DrawLine. If so, I don't know how to Dim g as Graphics.

Can you help me with that?

Thanks.
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 23645718
You wouldn't manually "Dim" any graphics at all...

Use the Graphics supplied in the PAINT() Event via the "e" parameter:

   ' in the Paint() Event
   e.Graphics.DrawLine(...)
0
 

Author Comment

by:LeeLiam
ID: 23650168
No joy.

I tried the e.Graphics.Drawline in the Panel_Paint event. It is still drawing the X's under the usercontrols. If I only had a ZOrder and could bring them to the top.

I tried forcing it to paint the usercontrols first, then the X's but they still come out underneath.

Any other ideas?

Thanks.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 23651435
Right...use the Paint() Event for the USERCONTROLs to draw your X's...so each UserControl will draw its own inactive columns.
0
 

Author Comment

by:LeeLiam
ID: 23655015
I have 16 usercontrols stacked in the panel. Each control has a series of numbers like 123 234 567 432 321, etc. Three digits seperated by spaces. So, the column is three digits wide and 16 rows (each row being a usercontrol) tall. When a column is inactive, I want something to cover the column. It could be an large elongated X or a rectangle or something to block out the column.

When I try to use drawline from the uc_Paint event, the screen flickers for a second, and nothing appears.

I have also tried ControlPaint.FillReversibleRectangle(rc, Color.DarkGray) to cover the columns. That works at first, but then they disappear at strange moments.

Any ideas?

Thanks.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 23661299
Not sure...I'd have to see more of your new code to figure out where the problem is...
0
 

Author Comment

by:LeeLiam
ID: 23661611
It hard to take a piece of code out of the larger project.

Perhaps a picture will show what I need. In the attachment, the gray filled rectangle indicates the inactive column. This is where I was trying to cover with a large X, but this rectangle will suffice.

The dark blue rectangle indicates the active column and moves with the mouse.

The dark blue rectangle is working well. The gray rectangle appears with the form opens, but at some point they disappear.

Does this make any sense?

Thanks.
column.jpg
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month20 days, 5 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question