| | |
Placing ComboxBox in DataGrid Cell -Visual Basic .Net Windows Forms
Please support our VB.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Placing ComboxBox in DataGrid Cell is a task usually found in Invoicing application. Here is my version of same.
Imports System.Data.SqlClient Public Class Form1 Dim cn As SqlConnection Dim cmd As SqlCommand Dim da As SqlDataAdapter Dim dr As SqlDataReader Dim ds As New DataSet Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load cn = New SqlConnection("Integrated Security=sspi;Initial Catalog =ShalvinPD;Data Source = .\sqlexpress") cn.Open() da = New SqlDataAdapter("select ProductName,Categoryid ,UnitPrice from Products", cn) da.Fill(ds, "products") DataGrid1.SetDataBinding(ds, "products") fillcombo() End Sub Private Sub DataGrid1_CurrentCellChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGrid1.CurrentCellChanged Dim x, y, w, h As Integer Dim rect As Rectangle rect = DataGrid1.GetCurrentCellBounds x = rect.X + DataGrid1.Left y = rect.Y + DataGrid1.Top w = rect.Width h = rect.Height ComboBox1.SetBounds(x, y, w, h) ComboBox1.Visible = True End Sub Private Sub fillcombo() cmd = New SqlCommand("select * from categories", cn) dr = cmd.ExecuteReader() While dr.Read() ComboBox1.Items.Add(dr("categoryName")) End While End Sub Private Sub DataGrid1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGrid1.MouseDown MessageBox.Show(e.X.ToString() + " " + e.Y.ToString() + " " + e.Button.ToString()) End Sub End Class Happy Programming
Similar Threads
- How to do basic file I/O in Visual C++ or in Visual C++ .NET (C++)
- Page numbers displayed in single cell in asp.net datagrid, why? (ASP.NET)
- Accessing Datagrid selected row cell value (c# .NET) (ASP.NET)
- How do i Make visual basic remember selections From other forms (Visual Basic 4 / 5 / 6)
- The Move.....Visual Basic 6, Visual Basic .NET ? (VB.NET)
| Thread Tools | Search this Thread |
.net .net2008 2005 2008 access account arithmetic array basic beginner browser button buttons center check code combo component crystalreport cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic dropdownlist excel fade file-dialog filter forms ftp generatetags hardcopy html images input insert intel listview monitor net networking number open output panel passingparameters peertopeervideostreaming picturebox picturebox1 picturebox2 port print printing problem problemwithinstallation project searchvb.net select serial settings shutdown socket sqlserver survey tcp temperature text textbox timespan toolbox transparency trim txttoxmlconverter updown user usercontol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic.net visualstudio visualstudio.net visualstudio2008 web winforms wpf wrapingcode year



