Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 150,043 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,619 people online right now. Registration is fast and FREE... Join Now!




VB.Net : Displaying data in DataGrid

 
Reply to this topicStart new topic

VB.Net : Displaying data in DataGrid

Sonia B
5 Mar, 2008 - 01:39 AM
Post #1

New D.I.C Head
*

Joined: 24 Feb, 2008
Posts: 12

The thing i want to do is in a datagrid there should be a combo box on the selection of which the other columns should

be filled.
The code so far i tried is
as follows
CODE


Dim ConString As String
        ConString = "Data Source=Ankita; Initial Catalog=Ankita; Integrated Security=True"
        Dim conn As New SqlConnection(ConString)
        Dim ds As New DataSet
      
        Dim ItemCode As New DataGridViewComboBoxColumn
        ItemCode.DataPropertyName = "ItemCode"
        ItemCode.Name = "ItemCode"

        ItemCode.Items.AddRange("C", "E", "M")

        Dim str As String
        str = "Select ItemDescription, ItemQuantity, ItemRate from ItemDetails"
        Dim da As New SqlDataAdapter(str, conn)
        da.Fill(ds, "ItemDetails")

        dgvItemDetails.DataSource = ds
        dgvItemDetails.DataMember = "ItemDetails"
        Me.dgvItemDetails.Columns.Add(ItemCode)
        

        dgvItemDetails.Columns("ItemCode").Width = 40




This gives me a combo box but there is much more to be done in which i want help.

Firstly, i am able create a new column having combo box but it appears at the end of the other columns which i dont

want i want it to appear as the 1st column. can some one help me in this.

Secondly, i want only the column names appear in the grid from the sql database and not its rows till i select it from the

combo.
How can i do this please help.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 09:57PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month