ComboBox border in black and with no view of the arrow in print

Answered ComboBox border in black and with no view of the arrow in print

  • Sunday, April 29, 2012 10:11 PM
     
     
    friends,

    I want to set a combobox with black margins and without seeing the arrow. In orderto stay only a box with black outline.

    How do I do?

All Replies

  • Sunday, April 29, 2012 10:27 PM
     
      Has Code

    Hello Vitor Patricio,

    friends,

    I want to set a combobox with black margins and without seeing the arrow. In orderto stay only a box with black outline.

    How do I do?

    with e.Graphics , see sample below with PanelControl

        Private Sub Form1_Paint(sender As System.Object, e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
            'My need is to have at the end, a border around a panel with,
            ' a side of 3px and black color,
            e.Graphics.DrawLine(New Pen(Color.Black, 3), Panel1.Location.X - 3, Panel1.Location.Y - 1, Panel1.Location.X + Panel1.Width + 3, Panel1.Location.Y - 1) '<< Top line.
            ' another side of 6px of red color,
            e.Graphics.DrawLine(New Pen(Color.Red, 6), Panel1.Location.X - 3, Panel1.Location.Y + Panel1.Height + 3, Panel1.Location.X + Panel1.Width + 3, Panel1.Location.Y + Panel1.Height + 3) '<< Use half the pen width for the bottom line.
            ' another side of 2px of green color
            e.Graphics.DrawLine(New Pen(Color.Green, 2), Panel1.Location.X - 2, Panel1.Location.Y, Panel1.Location.X - 2, Panel1.Location.Y + Panel1.Height) '<< Left side.
            ' and another side of 15px of blue color.
            e.Graphics.DrawLine(New Pen(Color.Blue, 15), Panel1.Location.X + Panel1.Width, Panel1.Location.Y, Panel1.Location.X + Panel1.Width, Panel1.Location.Y + Panel1.Height) '<< Right side.
        End Sub

    Regards.

  • Sunday, April 29, 2012 10:36 PM
     
     
    Hello Carmelo La Monica,

    I appreciate your comment.

    However I was referring to a combobox?

    Can you help me?
  • Sunday, April 29, 2012 10:49 PM
     
      Has Code

    Hello Vitor Patricio,

    Hello Carmelo La Monica,

    I appreciate your comment.

    However I was referring to a combobox?

    Can you help me?

    yes, the example was for a panel, to run it on a ComboBox control, and simply replace the object with the ComboBox panel1, something like this.

    Private Sub Form1_Paint(sender As System.Object, e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
            'My need is to have at the end, a border around a panel with,
            ' a side of 3px and black color,
            e.Graphics.DrawLine(New Pen(Color.Black, 2), ComboBox1.Location.X - 3, ComboBox1.Location.Y - 1, ComboBox1.Location.X + ComboBox1.Width + 3, ComboBox1.Location.Y - 1) '<< Top line.
            ' another side of 6px of red color,
            e.Graphics.DrawLine(New Pen(Color.Black, 2), ComboBox1.Location.X - 3, ComboBox1.Location.Y + ComboBox1.Height + 3, ComboBox1.Location.X + ComboBox1.Width + 3, ComboBox1.Location.Y + ComboBox1.Height + 3) '<< Use half the pen width for the bottom line.
            ' another side of 2px of green color
            e.Graphics.DrawLine(New Pen(Color.Black, 2), ComboBox1.Location.X - 2, ComboBox1.Location.Y, ComboBox1.Location.X - 2, ComboBox1.Location.Y + ComboBox1.Height) '<< Left side.
            ' and another side of 15px of blue color.
            e.Graphics.DrawLine(New Pen(Color.Black, 2), ComboBox1.Location.X + ComboBox1.Width, ComboBox1.Location.Y, ComboBox1.Location.X + ComboBox1.Width, ComboBox1.Location.Y + ComboBox1.Height) '<< Right side.
        End Sub

    where didthe color type,followed by the widthof the lineimmediately after,and calculationsto draw the lineon each side. With this example you should be able to draw 4 lines around the ComboBox.

    Regards.


  • Sunday, April 29, 2012 11:02 PM
     
     
    Is not working friend.
    You can not work this type of things directly on combobox?
  • Monday, April 30, 2012 8:43 PM
     
     
  • Monday, April 30, 2012 8:52 PM
    Moderator
     
     

    1)  how is the user supposed to change the selection if there is no dropdown arrow?

    2)  what are you printing that the combobox would appear in the print out?  why not just print the value in the combo box and draw a rectangle around it?


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

  • Monday, April 30, 2012 9:09 PM
     
     
    1) Only need the arrow and the black border effect to see in print.

    2) will appear in print what is selected.
  • Monday, April 30, 2012 9:16 PM
    Moderator
     
     

    If this only has to do with a print view of the data then there is no reason to modify the user control.

    How are you printing this data?  Are you using something like Form.DrawToBitmap in conjuction with a PrintDocument?


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

  • Monday, April 30, 2012 9:25 PM
     
     
    Yes I am using Form.DrawToBitmap in conjuction with the PrintDocument.
  • Monday, April 30, 2012 9:27 PM
     
      Has Code

    Vitor,

    Go to the ComboBox Properties and change the DroupDownStyle to Simple or just Use this code for your combobox in form load or print event:

    ComboBox1.DropDownStyle = ComboBoxStyle.Simple

    Now to set the Black Thick Boarder for your ComboBox I do not think that you can do that with the combobox. However you can add a PANEL from the toolbox and set the PANEL boarders to what you want then insert the combobox inside it.

    Regards,



    • Edited by sallemander Monday, April 30, 2012 9:28 PM
    • Edited by sallemander Monday, April 30, 2012 9:51 PM
    •  
  • Monday, April 30, 2012 10:03 PM
     
     
    friend,

    The idea of ​​the panel is excellent.
    However when I put this code: = ComboBox1.DropDownStyleComboBoxStyle.Simple, let you can select one of the names of the variousnames.

    How do I do?
  • Monday, April 30, 2012 10:08 PM
     
     

    Vitor,

    Just add the code to the print button event so it will be (simple) only after you selected the item and ready to print. Or just add it to a button event.

    Regards,

  • Monday, April 30, 2012 10:18 PM
     
     
    With the combobox so you can not select anything. The box no longer has that option.
  • Monday, April 30, 2012 10:27 PM
     
     Answered Has Code

    Vitor,

    Add the code to an event so when you load your application the combobox should not be effected with the code yet.  After you select or add an item to the ComboBox then once you click on the print button or a button it will change the style to simple and what ever you selcted earlier it should be there.

    for example:

    Public Class Form1
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            ComboBox1.Items.Add("Dan")
            ComboBox1.Items.Add("John")
            ComboBox1.Items.Add("Mark")
            ComboBox1.Items.Add("David")
        End Sub
     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            ComboBox1.DropDownStyle = ComboBoxStyle.Simple
        End Sub
    End Class

    The code is working fine. Just add a ComboBox and a Button to a form and try it.

    Good Luck,

  • Monday, April 30, 2012 11:02 PM
     
     
    Sallemander,

    Very good! Thanked!

    Reviewing code is, but my program is prepared to enter / delete the names in the program itself; APPEARED ME AN IDEA.

    I put a button with your code: ComboBox1.DropDownStyle =ComboBoxStyle.Simple

    Then put another button to print.

    This solves!

    Hug, my friend.
  • Monday, April 30, 2012 11:12 PM
     
     
    You are welcome.
  • Sunday, June 10, 2012 10:59 PM
     
     

    Hello, friend.

    I am in need of your help in my thread:

    Center the text of a combobox Does it help me?

    greetings