How to color different elements of a ComboBox?How to style a <select> dropdown with only CSS?What is a NullReferenceException, and how do I fix it?Hide DropDownList in ComboBoxHow to make Twitter Bootstrap menu dropdown on hover rather than clickdon't want editable combobox to change itemssourceHow to draw the static part of the comboboxHow to create ColorComboBox and bind its ValueMember to Color property of my class object?gridview selected row backcolorChange highlight color of combobox item WPFC# ComboBox SelectedItem not Updating
Scaffoldings in New York
Can non-English-speaking characters use wordplay specific to English?
Modern approach to radio buttons
Is CD audio quality good enough for the final delivery of music?
What is the difference between nullifying your vote and not going to vote at all?
How were these pictures of spacecraft wind tunnel testing taken?
What are the problems in teaching guitar via Skype?
Why does the UK have more political parties than the US?
Is floating in space similar to falling under gravity?
Is my router's IP address really public?
shutdown at specific date
Solmization with syllables - du da di
Tic-Tac-Toe for the terminal
Yandex Programming Contest: Alarms
What is the best linguistic term for describing the kw > p / gw > b change, and its usual companion s > h
How can I prevent interns from being expendable?
Is there any use case for the bottom type as a function parameter type?
Smart people send dumb people to a new planet on a space craft that crashes into a body of water
Do you play the upbeat when beginning to play a series of notes, and then after?
Probability of fraction not being able to be simplified
Infinitely many hats
1960s sci-fi novella with a character who is treated as invisible by being ignored
How to extract lower and upper bound in numeric format from a confidence interval string?
How do Russian speakers idiomatically express the idea of "Ce n’est pas donné à tout le monde de ..." in French?
How to color different elements of a ComboBox?
How to style a <select> dropdown with only CSS?What is a NullReferenceException, and how do I fix it?Hide DropDownList in ComboBoxHow to make Twitter Bootstrap menu dropdown on hover rather than clickdon't want editable combobox to change itemssourceHow to draw the static part of the comboboxHow to create ColorComboBox and bind its ValueMember to Color property of my class object?gridview selected row backcolorChange highlight color of combobox item WPFC# ComboBox SelectedItem not Updating
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
As far as I was told and as I read about it, the ComboBox with the property DropDownStyle set to DropDownList is a combination of:
A TextBox that doesn't show a cursor and only shows items when the user presses UP, DOWN, or keys equivalent to the items on the list. E.g., if there's an item named INPUT and an item named OUTPUT on the DropDownList, by pressing the key I the ComboBox would show INPUT, while pressing the key O would show OUTPUT;
A Button that shows the DropDownList;
A DropDownList, which only drops when the user presses the Button.
Assuming the above is correct, let me mention what I've tried so far. I've searched ways of manipulating the three elements I mentioned above and found some answers, unfortunately most of them were related to ASP.NET and C#.NET.
I've successfully set the BackColor and ForeColor of both default and selected state of the items on the DropDownList.
I've tried drawing a Rectangle over the border of the element TextBox and the element DropDownList of this ComboBox, but these rectangles stay beneath the actual borders.
Private Sub cmbType_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles cmbType.DrawItem
Dim itemBackColorDefault As Brush, itemForeColorDefault As Brush
Dim itemBackColorSelected As Brush, itemForeColorSelected As Brush
itemBackColorDefault = Brushes.DarkGray
itemForeColorDefault = Brushes.WhiteSmoke
itemBackColorSelected = Brushes.WhiteSmoke
itemForeColorSelected = Brushes.DarkGray
Dim myPen As Pen
Dim myGraphics As Graphics = Me.CreateGraphics
myPen = New Pen(Drawing.Color.Red, 1)
myGraphics.DrawRectangle(myPen, 133, 25, 130, 20) 'Supposed to draw a red rectangle above the border of the element TextBox of cmbType, but it stays beneath it
e.Graphics.DrawRectangle(myPen, -1, -1, 130, 31) 'Supposed to draw a red rectangle above the border of the element DropDownList of cmbType when the element Button of cmbType is clicked, but, again, it stays beneath it
If e.Index < 0 Then Exit Sub
Dim rct As Rectangle = e.Bounds
Dim itemText As String = cmbType.Items(e.Index)
If e.State And DrawItemState.Selected Then
'Selected BackColor
e.Graphics.FillRectangle(itemBackColorSelected, rct)
'Selected ForeColor
e.Graphics.DrawString(itemText, Me.cmbType.Font, itemForeColorSelected, rct.X, rct.Y)
Else
'Default BackColor
e.Graphics.FillRectangle(itemBackColorDefault, rct)
'Default ForeColor
e.Graphics.DrawString(itemText, Me.cmbType.Font, itemForeColorDefault, rct.X, rct.Y)
End If
End Sub
The expected result and actual result can be summarized in one image:
LEFT is the actual result, RIGHT is the expected result.
To be more specific, what I want to change is as follow.
TextBox: border color;
Button: border color and BackColor, arrow color and shape;
DropDownList: border color (both default state and selected state).
vb.net drop-down-menu combobox
add a comment |
As far as I was told and as I read about it, the ComboBox with the property DropDownStyle set to DropDownList is a combination of:
A TextBox that doesn't show a cursor and only shows items when the user presses UP, DOWN, or keys equivalent to the items on the list. E.g., if there's an item named INPUT and an item named OUTPUT on the DropDownList, by pressing the key I the ComboBox would show INPUT, while pressing the key O would show OUTPUT;
A Button that shows the DropDownList;
A DropDownList, which only drops when the user presses the Button.
Assuming the above is correct, let me mention what I've tried so far. I've searched ways of manipulating the three elements I mentioned above and found some answers, unfortunately most of them were related to ASP.NET and C#.NET.
I've successfully set the BackColor and ForeColor of both default and selected state of the items on the DropDownList.
I've tried drawing a Rectangle over the border of the element TextBox and the element DropDownList of this ComboBox, but these rectangles stay beneath the actual borders.
Private Sub cmbType_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles cmbType.DrawItem
Dim itemBackColorDefault As Brush, itemForeColorDefault As Brush
Dim itemBackColorSelected As Brush, itemForeColorSelected As Brush
itemBackColorDefault = Brushes.DarkGray
itemForeColorDefault = Brushes.WhiteSmoke
itemBackColorSelected = Brushes.WhiteSmoke
itemForeColorSelected = Brushes.DarkGray
Dim myPen As Pen
Dim myGraphics As Graphics = Me.CreateGraphics
myPen = New Pen(Drawing.Color.Red, 1)
myGraphics.DrawRectangle(myPen, 133, 25, 130, 20) 'Supposed to draw a red rectangle above the border of the element TextBox of cmbType, but it stays beneath it
e.Graphics.DrawRectangle(myPen, -1, -1, 130, 31) 'Supposed to draw a red rectangle above the border of the element DropDownList of cmbType when the element Button of cmbType is clicked, but, again, it stays beneath it
If e.Index < 0 Then Exit Sub
Dim rct As Rectangle = e.Bounds
Dim itemText As String = cmbType.Items(e.Index)
If e.State And DrawItemState.Selected Then
'Selected BackColor
e.Graphics.FillRectangle(itemBackColorSelected, rct)
'Selected ForeColor
e.Graphics.DrawString(itemText, Me.cmbType.Font, itemForeColorSelected, rct.X, rct.Y)
Else
'Default BackColor
e.Graphics.FillRectangle(itemBackColorDefault, rct)
'Default ForeColor
e.Graphics.DrawString(itemText, Me.cmbType.Font, itemForeColorDefault, rct.X, rct.Y)
End If
End Sub
The expected result and actual result can be summarized in one image:
LEFT is the actual result, RIGHT is the expected result.
To be more specific, what I want to change is as follow.
TextBox: border color;
Button: border color and BackColor, arrow color and shape;
DropDownList: border color (both default state and selected state).
vb.net drop-down-menu combobox
add a comment |
As far as I was told and as I read about it, the ComboBox with the property DropDownStyle set to DropDownList is a combination of:
A TextBox that doesn't show a cursor and only shows items when the user presses UP, DOWN, or keys equivalent to the items on the list. E.g., if there's an item named INPUT and an item named OUTPUT on the DropDownList, by pressing the key I the ComboBox would show INPUT, while pressing the key O would show OUTPUT;
A Button that shows the DropDownList;
A DropDownList, which only drops when the user presses the Button.
Assuming the above is correct, let me mention what I've tried so far. I've searched ways of manipulating the three elements I mentioned above and found some answers, unfortunately most of them were related to ASP.NET and C#.NET.
I've successfully set the BackColor and ForeColor of both default and selected state of the items on the DropDownList.
I've tried drawing a Rectangle over the border of the element TextBox and the element DropDownList of this ComboBox, but these rectangles stay beneath the actual borders.
Private Sub cmbType_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles cmbType.DrawItem
Dim itemBackColorDefault As Brush, itemForeColorDefault As Brush
Dim itemBackColorSelected As Brush, itemForeColorSelected As Brush
itemBackColorDefault = Brushes.DarkGray
itemForeColorDefault = Brushes.WhiteSmoke
itemBackColorSelected = Brushes.WhiteSmoke
itemForeColorSelected = Brushes.DarkGray
Dim myPen As Pen
Dim myGraphics As Graphics = Me.CreateGraphics
myPen = New Pen(Drawing.Color.Red, 1)
myGraphics.DrawRectangle(myPen, 133, 25, 130, 20) 'Supposed to draw a red rectangle above the border of the element TextBox of cmbType, but it stays beneath it
e.Graphics.DrawRectangle(myPen, -1, -1, 130, 31) 'Supposed to draw a red rectangle above the border of the element DropDownList of cmbType when the element Button of cmbType is clicked, but, again, it stays beneath it
If e.Index < 0 Then Exit Sub
Dim rct As Rectangle = e.Bounds
Dim itemText As String = cmbType.Items(e.Index)
If e.State And DrawItemState.Selected Then
'Selected BackColor
e.Graphics.FillRectangle(itemBackColorSelected, rct)
'Selected ForeColor
e.Graphics.DrawString(itemText, Me.cmbType.Font, itemForeColorSelected, rct.X, rct.Y)
Else
'Default BackColor
e.Graphics.FillRectangle(itemBackColorDefault, rct)
'Default ForeColor
e.Graphics.DrawString(itemText, Me.cmbType.Font, itemForeColorDefault, rct.X, rct.Y)
End If
End Sub
The expected result and actual result can be summarized in one image:
LEFT is the actual result, RIGHT is the expected result.
To be more specific, what I want to change is as follow.
TextBox: border color;
Button: border color and BackColor, arrow color and shape;
DropDownList: border color (both default state and selected state).
vb.net drop-down-menu combobox
As far as I was told and as I read about it, the ComboBox with the property DropDownStyle set to DropDownList is a combination of:
A TextBox that doesn't show a cursor and only shows items when the user presses UP, DOWN, or keys equivalent to the items on the list. E.g., if there's an item named INPUT and an item named OUTPUT on the DropDownList, by pressing the key I the ComboBox would show INPUT, while pressing the key O would show OUTPUT;
A Button that shows the DropDownList;
A DropDownList, which only drops when the user presses the Button.
Assuming the above is correct, let me mention what I've tried so far. I've searched ways of manipulating the three elements I mentioned above and found some answers, unfortunately most of them were related to ASP.NET and C#.NET.
I've successfully set the BackColor and ForeColor of both default and selected state of the items on the DropDownList.
I've tried drawing a Rectangle over the border of the element TextBox and the element DropDownList of this ComboBox, but these rectangles stay beneath the actual borders.
Private Sub cmbType_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles cmbType.DrawItem
Dim itemBackColorDefault As Brush, itemForeColorDefault As Brush
Dim itemBackColorSelected As Brush, itemForeColorSelected As Brush
itemBackColorDefault = Brushes.DarkGray
itemForeColorDefault = Brushes.WhiteSmoke
itemBackColorSelected = Brushes.WhiteSmoke
itemForeColorSelected = Brushes.DarkGray
Dim myPen As Pen
Dim myGraphics As Graphics = Me.CreateGraphics
myPen = New Pen(Drawing.Color.Red, 1)
myGraphics.DrawRectangle(myPen, 133, 25, 130, 20) 'Supposed to draw a red rectangle above the border of the element TextBox of cmbType, but it stays beneath it
e.Graphics.DrawRectangle(myPen, -1, -1, 130, 31) 'Supposed to draw a red rectangle above the border of the element DropDownList of cmbType when the element Button of cmbType is clicked, but, again, it stays beneath it
If e.Index < 0 Then Exit Sub
Dim rct As Rectangle = e.Bounds
Dim itemText As String = cmbType.Items(e.Index)
If e.State And DrawItemState.Selected Then
'Selected BackColor
e.Graphics.FillRectangle(itemBackColorSelected, rct)
'Selected ForeColor
e.Graphics.DrawString(itemText, Me.cmbType.Font, itemForeColorSelected, rct.X, rct.Y)
Else
'Default BackColor
e.Graphics.FillRectangle(itemBackColorDefault, rct)
'Default ForeColor
e.Graphics.DrawString(itemText, Me.cmbType.Font, itemForeColorDefault, rct.X, rct.Y)
End If
End Sub
The expected result and actual result can be summarized in one image:
LEFT is the actual result, RIGHT is the expected result.
To be more specific, what I want to change is as follow.
TextBox: border color;
Button: border color and BackColor, arrow color and shape;
DropDownList: border color (both default state and selected state).
vb.net drop-down-menu combobox
vb.net drop-down-menu combobox
asked Mar 24 at 8:58
Thomas A. RodriguezThomas A. Rodriguez
84
84
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55322145%2fhow-to-color-different-elements-of-a-combobox%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55322145%2fhow-to-color-different-elements-of-a-combobox%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown