473,396 Members | 1,816 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,396 software developers and data experts.

ComboBox links

Preface: I have viewed the combobox control video at Microsoft.at the
movies.

I want to simulate an HTML combobox as a windows application combobox with 5
to 10 selections in each box.
In the HTML form:
<option value="help.htm">More Info</option>

Thing is: I want to put the URL description "More Info" into the combobox
list, not the URL "help.htm."
URL's have too many characters for a width restricted combobox. Is there a
better way using the IDE?
If not, what programmatic control structure should I use to incorporate the
three subs (noted below) for each linklabel of the combobox? The design
calls for three of these combo boxes positioned in a horizontal row across
the page.

The vb.net code for a single linklabel is:

Private Sub llHelp_LinkClicked(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.LinkLabelLinkClickedEventArgs ) Handles
llHelp.LinkClicked
Try
VisitHelp()
Catch ex As Exception
MyErrors()
End Try
End Sub
----------------
Sub VisitHelp()
llHelp.LinkVisited = True
System.Diagnostics.Process.Start("help.htm")
End Sub
----------------
Private Sub MyErrors()
MessageBox.Show("The link returned an error message.")
End Sub
========
Not very efficient for use in a combobox with 5 or more selection strings.
--
Crossposting:
I posted this msg in .controls but got 0 hits on the problem.
--
Dennis D.
http://www.dennisys.com/
Nov 21 '05 #1
8 2053
Dennis,

Sorry, however I think that in this way, you get not the answers you could
have got when you wrote clear problems and not as a kind of puzzles.

There is no HTML Combobox.

There is a HTML drowdown and an ASPX dropdownlist.

In a windowform there is a ComboBox.

In this way you will not get much answers in my opinion.

First of all are Combobox problems in my opinion the moist avoided to answer
in this newsgroup.

Second when the message is opened it is opened by Winform persons, and the
Webform persons skip it.

What are you after a webform or a winform application.

Cor
Nov 21 '05 #2
Thanks for the response Cor:

D.
Nov 21 '05 #3
If I succeed in creating the winapp control I'll transmit a code snippet.
Sorry, however I think that in this way, you get not the answers you could
have got when you wrote clear problems and not as a kind of puzzles. Cor

D.
Nov 21 '05 #4
Ok Cor; As Promised:
This is the skimpy version of a combobox that opens URL's in a browser.
It consists of a combobox and a listbox.
The combobox holds the url description, and the listbox holds the actual
url.
I haven't tested it further than initial construction. Development time: 30
minutes.

Public Class Pulldown
Inherits System.Windows.Forms.Form
Public link As Integer
Public linkUrl As String
Windows Form Designer Code


Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If ComboBox1.SelectedIndex > 0 Then
link = ComboBox1.SelectedIndex
ListBox1.SelectedIndex = link
linkUrl = ListBox1.Text
makelink(linkUrl)
End If
End Sub
----------------------
Private Sub makelink(ByRef link As String)
System.Diagnostics.Process.Start(linkUrl)
End Sub

End Class
Nov 21 '05 #5
Change this: ByRef link to:
Private Sub makelink(ByRef linkURL As String)
Nov 21 '05 #6
And probably throw this in to so the form loads:
Private Sub Pulldown_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

End Sub
Nov 21 '05 #7
Dennis,

I took some time to show you how I would have probably done this.
However first the passing by ref or by value. Try to use forever by value
when you don't want to change that value and be aware that when that value
is an object, it will be changed when you change something inside.
(Therefore you can for a reference type always use a sub and have not return
something)

Because of the fact that a string is immutable it will be passed by a
reference in the value, however you cannot change it inside the routine,
because that refs changes as quick that you change something. (While the
original string stays the same).

The samples.

The first one is what I changed from your sample.
The second one is how I would probably do that when it was my goal (I don't
think it will ever be in this way, however that is not my problem, try them
both because the second one has a much nicer behaviour you can select from
both places).

You can see that I avoided any global variable beside the designer part.

\\\needs one combobox and a listbox
Private Sub Form9_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
ComboBox1.Items.Add("Microsoft")
ComboBox1.Items.Add("MSDN")
ListBox1.Items.Add("http:\\www.microsoft.com")
ListBox1.Items.Add("http:\\msdn.microsoft.com")
ComboBox1.SelectedIndex = 0
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender _
As System.Object, ByVal e As System.EventArgs) Handles _
ComboBox1.SelectedIndexChanged
ListBox1.SelectedIndex = ComboBox1.SelectedIndex
System.Diagnostics.Process.Start(ListBox1.Text)
End Sub
///
\\\needs one combobox and a listbox
Private Sub Form10_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim dt As New DataTable
dt.Columns.Add("Text")
dt.Columns.Add("Link")
For i As Integer = 0 To 1
dt.Rows.Add(dt.NewRow)
Next
dt.Rows(0).ItemArray = New Object() _
{"Microsoft", "http:\\www.microsoft.com"}
dt.Rows(1).ItemArray = New Object() _
{"MSDE", "http:\\msdn.microsoft.com"}
ComboBox1.DataSource = dt.DefaultView
ComboBox1.DisplayMember = "Text"
ListBox1.DataSource = dt.DefaultView
ListBox1.DisplayMember = "Link"
ComboBox1.SelectedIndex = -1
ComboBox1.Text = "Select"
AddHandler ComboBox1.SelectedIndexChanged, AddressOf PosChanged
AddHandler ListBox1.SelectedIndexChanged, AddressOf PosChanged
End Sub
Private Sub PosChanged(ByVal sender _
As System.Object, ByVal e As System.EventArgs)
Dim dv As DataView = DirectCast(ComboBox1.DataSource, DataView)
Dim cp As Integer = DirectCast(BindingContext(dv),
CurrencyManager).Position
System.Diagnostics.Process.Start(dv(cp)("Link").To String)
End Sub
///
I hope this helps?

Cor
Nov 21 '05 #8
Thank you very much Cor:
Your reply will help in my quest to learn to use the language. I only have
significant time on the weekends, so this type of feedback is immensely
helpful. The project I'm working on is my first vb application, and it is
not psuedo-coded. It is being pieced together when something occurs to me
might be helpful to include. Probably the second version will be much more
structured and better coded as I learn more, especially through examples
like the ones you have provided.

Thanks again.

D.

"Cor Ligthert" <no************@planet.nl> wrote in message
news:e6**************@TK2MSFTNGP12.phx.gbl...

Nov 21 '05 #9

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

Similar topics

2
by: john sutor | last post by:
Does anyone know how to create a combobox in a standard datagrid? I can create check boxes , but not the combobox
3
by: TT (Tom Tempelaere) | last post by:
Hay there, I'm writing my own DataGridComboBoxColumn because .NET 1.1 does not have one (I hope .NET 2.0 supplies one). I based it on this article:...
4
by: Lars Netzel | last post by:
I want a datagrid cell to be a combobox (based on database records) and when you select a value in the combobox I want to add info to cells on the same row in the datagrid but with More info from...
2
by: Ing. Rajesh Kumar | last post by:
Hi everybody I am a web developer now trying to do something in WinForms using VB.NET and have a small problem with ComboBox. I just wanted to ask what is the equivalent to the following web code...
1
by: Mike Swans | last post by:
Has anyone any solutions to multicolumns dropdown combobox? Like to see how to implement it. Thanks!
4
by: Vish | last post by:
Hi, I need to make the text on a combobox that is disabled to be drawn with a black color. I was not able to find any help on this online. The drawItem seems to apply only for the dropdpwn...
2
by: mfleet1973 | last post by:
Hello (again), Within my datagrid I add a control to the datagridtextboxcolumn when the underlying textbox receives focus as follows: Combobox1.Size = New...
13
by: honey99 | last post by:
Hi! I have to fix a problem in JSP.Actually,i have a JSP page say Ex1.jsp.In this Ex1.jsp i have an anchor tag which links into another JSP page i.e when i click on the link another pop-up window...
14
by: Mark | last post by:
I have a table with a field that uses a combobox to populate values. The Lookup tab within table design mode is the following: Display Control Combo Box Row Source Type ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.