Solved

Visual studio on click

Posted on 2008-11-02
7
259 Views
Last Modified: 2013-11-26
Hi

I am just starting to use visual studio, can anyone give me an example of code that returns values to a list box on the click of a button. I'm not bothered what the values are just won't to see how its done?

Thanks
0
Comment
Question by:ac_davis2002
  • 4
  • 3
7 Comments
 
LVL 13

Expert Comment

by:sm394
ID: 22861960
0
 

Author Comment

by:ac_davis2002
ID: 22861977
I will take a look, i am trying to use vB2005 do you have any examples using that?
0
 
LVL 13

Expert Comment

by:sm394
ID: 22861997
VB2005 with ASP.NET or desktop applications ?
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 13

Expert Comment

by:sm394
ID: 22862029
with asp.net/VB.Net you can do something like this
ASPX FILE
=====================
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="ListBox_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:ListBox runat="server" ID="lstbxTest">
   
    </asp:ListBox>
    <asp:TextBox runat="server" ID="txtTest"></asp:TextBox>
    <asp:Button runat="server" ID="btnAdd" Text="Add" />
   
    </div>
    </form>
</body>
</html>

==============CODE BEHIND=======================


Partial Class ListBox_Default
    Inherits System.Web.UI.Page

    Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        lstbxTest.Items.Add(New ListItem(txtTest.Text, txtTest.Text))

    End Sub
End Class

0
 

Author Comment

by:ac_davis2002
ID: 22862040
sorry I'm using windows applications

I really just want to see a command to populate a list box with values, do I need to use asp to do this?
0
 
LVL 13

Accepted Solution

by:
sm394 earned 500 total points
ID: 22862072

drop a listbox and button control on windows form
then on click event of button
do this
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ListBox1.Items.Add("Test")
    End Sub
0
 

Author Closing Comment

by:ac_davis2002
ID: 31512503
cool thanks!!
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

778 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