| | |
Combobox selected value - colored in datagridview
Please support our MS SQL advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jun 2008
Posts: 117
Reputation:
Solved Threads: 0
Hi I have 4 comboboxes..and any value that I choose.. I get a whole set of fields displayed in my datagrid view..
I want to make a difference..the value that I choose in the combobox, has to appear green in color in my datagridview. How do I do this ? I am not sure what property i have to use.. my code is as follows.. I dont want to use a T-SQL to display only limited records.. I want colored records in the datagridview..! please assist
I want to make a difference..the value that I choose in the combobox, has to appear green in color in my datagridview. How do I do this ? I am not sure what property i have to use.. my code is as follows.. I dont want to use a T-SQL to display only limited records.. I want colored records in the datagridview..! please assist
MS SQL Syntax (Toggle Plain Text)
Imports System.Windows.forms Imports System.DATA.oledb Public Class Form1 Private Sub Form1_Load(ByVal sender AS System.Object, ByVal e AS System.EventArgs) Handles MyBase.LOAD Dim objcmd AS New DATA.OleDb.OleDbCommand Dim objrdr AS DATA.OleDb.OleDbDataReader Dim TableName AS String = "" Dim query AS String = "" Dim cbo AS ComboBox = Nothing Dim con AS New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=C:\Documents and Settings\bashkark\Desktop\Final Database.mdb") con.Open() FOR x AS Int32 = 1 TO 5 SELECT Case x Case 1 query = "SELECT DISTINCT Mfg FROM table1 WHERE Mfg IS NOT NULL ORDER BY Mfg" TableName = "Mfg" cbo = ComboBox1 Case 2 query = "SELECT DISTINCT MAKE FROM table1 WHERE MAKE IS NOT NULL ORDER BY MAKE" TableName = "Make" cbo = ComboBox2 Case 3 query = "SELECT DISTINCT GRAPHICSCARD FROM table1 WHERE GRAPHICSCARD IS NOT NULL ORDER BY GRAPHICSCARD" TableName = "GRAPHICSCARD" cbo = ComboBox3 Case 4 query = "SELECT DISTINCT GRAPHICSVERSION FROM table1 WHERE GRAPHICSVERSION IS NOT NULL ORDER BY GRAPHICSVERSION" TableName = "GRAPHICSVERSION" cbo = ComboBox4 End SELECT objcmd.Connection = con objcmd.CommandText = query objrdr = objcmd.ExecuteReader cbo.Items.Clear() IF objrdr.HasRows Then Do While objrdr.READ cbo.Items.ADD(objrdr.GetValue(0)) Loop End IF objrdr.Close() Next End Sub Private Sub Button5_Click(ByVal sender AS System.Object, ByVal e AS System.EventArgs) Handles Button5.Click End End Sub Private Sub Button3_Click(ByVal sender AS System.Object, ByVal e AS System.EventArgs) Handles Button3.Click Dim con AS OleDbConnection = New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=C:\Documents and Settings\bashkark\Desktop\Final Database.mdb") Dim cmd AS New OleDbCommand cmd = New OleDbCommand("Select * from table2 ", con) con.Open() Dim da AS OleDbDataAdapter = New OleDbDataAdapter(cmd) Try Dim ds AS DataSet = New DataSet() ds.TABLES.ADD("table2") da.Fill(ds, "table2") DataGridView1.DataSource = ds.TABLES("table2").DefaultView datagridview1. Finally con.Close() cmd = Nothing da.Dispose() con.Dispose() End Try End Sub End Class
Last edited by peter_budo; Aug 1st, 2008 at 12:39 pm. Reason: Use [code] tags not [quote] ! ! !
Hi,
My friend, your question have nothing to do with MSSQL, you should have posted it in Vb.net forum and i think you will need to use Cellstye.forecolor=Color.green
My friend, your question have nothing to do with MSSQL, you should have posted it in Vb.net forum and i think you will need to use Cellstye.forecolor=Color.green
It is never about the number of languages you know, you either have the logic of programming or you don't ...
Some of the codes I post are collected from different sites during the past couple of years, so I would like to thank them for their help and for enabling me to help.
Some of the codes I post are collected from different sites during the past couple of years, so I would like to thank them for their help and for enabling me to help.
![]() |
Other Threads in the MS SQL Forum
- Previous Thread: Help Figuring Out Proper Database Schema/Design
- Next Thread: creating pivot table
| Thread Tools | Search this Thread |





