1 Replies - 2828 Views - Last Post: 19 November 2009 - 01:38 PM Rate Topic: -----

#1 lasha34   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 19-November 09

Adding a ComboBox to DataGridView

Posted 19 November 2009 - 10:06 AM

Hello
I have datagridview connected with sql datebase and i want to add combobox to datagridvew (example:Time1 column)
Option Explicit On
Imports System.Data
Imports System.Data.SqlClient

Public Class Form1
	Private ConnectionString = "Data Source=.\sqlexpress;Initial Catalog=sk_db;Integrated Security=True"
	Private Conn As SqlConnection
	Private strSQL As String
	Private m_DataSet As DataSet

	Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

		strSQL = "SELECT id,CONVERT(varchar(35), tb1.Time1, 108) As Time1,comment,description FROM dbo.tb1"

		Conn = New SqlConnection(ConnectionString)
		Dim data_Adapter As SqlDataAdapter

		data_Adapter = New SqlDataAdapter(strSQL, Conn)
		data_Adapter.TableMappings.Add("Table", "tb1")

		m_DataSet = New DataSet()
		data_Adapter.Fill(m_DataSet)

		DataGridView1.DataSource = m_DataSet
		DataGridView1.DataMember = "tb1"

is any solution?

This post has been edited by lasha34: 19 November 2009 - 10:14 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Adding a ComboBox to DataGridView

#2 sharpy   User is offline

  • D.I.C Regular
  • member icon

Reputation: 38
  • View blog
  • Posts: 396
  • Joined: 02-June 07

Re: Adding a ComboBox to DataGridView

Posted 19 November 2009 - 01:38 PM

Hi

Select your datagridview on your form then select the arrow at the top right corner of the datagridview.

Select add column

Underneath the column name it asks you what type of column you want

Select Datagridview combobox column.

Hope this helps
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1