Click here to Skip to main content
16,016,535 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questionwhat is right way to handle? Pin
srisant14-Jan-09 20:45
srisant14-Jan-09 20:45 
AnswerRe: what is right way to handle? Pin
N a v a n e e t h14-Jan-09 23:02
N a v a n e e t h14-Jan-09 23:02 
GeneralRe: what is right way to handle? Pin
Manas Bhardwaj15-Jan-09 2:01
professionalManas Bhardwaj15-Jan-09 2:01 
GeneralRe: what is right way to handle? Pin
N a v a n e e t h16-Jan-09 5:05
N a v a n e e t h16-Jan-09 5:05 
QuestionVb integration with mainframe Pin
usharaniA14-Jan-09 20:24
usharaniA14-Jan-09 20:24 
AnswerRe: Vb integration with mainframe Pin
Ashfield15-Jan-09 1:24
Ashfield15-Jan-09 1:24 
AnswerRe: Vb integration with mainframe Pin
Dave Kreskowiak15-Jan-09 4:30
mveDave Kreskowiak15-Jan-09 4:30 
QuestionDataGridViewCombobox EditingControlShowing event Pin
sahahima14-Jan-09 19:12
sahahima14-Jan-09 19:12 
Hello,

I have a datagridview it contains 3 comboboxes, when combo1(category) is selected, the combo2(sub-Category) will display, when the combo2(sub-Category) is selected combo3(price) will display. every thing is working fine for the first row. when i do same thing in the second row the combo2 contains the previous sub-category and combo3 contains previous price how to restrict it.

please go throught the code if something is missing

code:

Public ddlCategory As DataGridViewComboBoxColumn = New DataGridViewComboBoxColumn()
Public ddlSubCategory As DataGridViewComboBoxColumn = New DataGridViewComboBoxColumn()
Public ddlPrice As DataGridViewComboBoxColumn = New DataGridViewComboBoxColumn()
-----------------------------------------------------------------
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ddlCategory.Name = "Category"
ddlSubCategory.Name = "SubCategory"
ddlPrice.Name = "Price"

DataGridView1.Columns.Insert(0, ddlCategory)
DataGridView1.Columns.Insert(1, ddlSubCategory)
DataGridView1.Columns.Insert(2, ddlPrice)

Dim scmd As String = "select distinct Category from master"
Dim sqlda As New SqlDataAdapter(scmd, strCon)
sqlda.Fill(DS, "ProjNo")

ddlCategory.DataSource = DS.Tables("Category")
ddlCategory.DisplayMember = "Category"
ddlCategory.ValueMember = "Category"
sqlda.Dispose()
sqlda = Nothing

DataGridView1.Rows.Add(3)

End Sub
------------------------------------------------------------------------
Private Sub DataGridView1_EditingControlShowing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles DataGridView1.EditingControlShowing
cb = TryCast(e.Control, ComboBox)
If cb IsNot Nothing Then
RemoveHandler cb.SelectedIndexChanged, AddressOf DGVddlCategoryComboIndexChanged
RemoveHandler cb.SelectedIndexChanged, AddressOf DGVddlSubCategoryComboIndexChanged

Select Case gvMultipleProjects.CurrentCell.ColumnIndex
Case 0
AddHandler cb.SelectedIndexChanged, AddressOf DGVddlCategoryComboIndexChanged
Case 1
AddHandler cb.SelectedIndexChanged, AddressOf DGVddlSubCategoryComboIndexChanged
End Select
End If
End Sub


----------------------------------------------------------------------
Private Sub DGVddlddlCategoryComboIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim com As ComboBox = CType(sender, ComboBox)

Dim scmd As String = "select distinct SubCategory from master where Category='" & com.SelectedItem.ToString() & "'"
Dim sqlda As New SqlDataAdapter(scmd, strCon)
sqlda.Fill(DS, "ProjNo")

ddlSubCategory.DataSource = DS.Tables("SubCategory")
ddlSubCategory.DisplayMember = "SubCategory"
ddlSubCategory.ValueMember = "SubCategory"
sqlda.Dispose()
sqlda = Nothing

RemoveHandler cb.SelectedIndexChanged, AddressOf DGVddlCategoryComboIndexChanged
RemoveHandler cb.SelectedIndexChanged, AddressOf DGVddlProjNoComboIndexChanged
End Sub

----------------------------------------------------------------
Private Sub DGVddlSubCategoryComboIndexChanged(ByVal sender As Object, ByVal e As EventArgs)

Dim com As ComboBox = CType(sender, ComboBox)
Dim scmd As String = "select price from master where SubCategory=" & com.SelectedValue.ToString() & ""
Dim sqlda As New SqlDataAdapter(scmd, strCon)
sqlda.Fill(DS, "Price")

ddlPrice.DataSource = DS.Tables("Price")
ddlPrice.DisplayMember = "Price"
ddlPrice.ValueMember = "id"

sqlda.Dispose()
sqlda = Nothing

RemoveHandler cb.SelectedIndexChanged, AddressOf DGVddlCategoryComboIndexChanged
RemoveHandler cb.SelectedIndexChanged, AddressOf DGVddlSubCategoryComboIndexChanged

End Sub


Thanks in advance
saha
AnswerRe: DataGridViewCombobox EditingControlShowing event Pin
Dave Kreskowiak15-Jan-09 4:27
mveDave Kreskowiak15-Jan-09 4:27 
QuestionRe: DataGridViewCombobox EditingControlShowing event Pin
sahahima15-Jan-09 19:35
sahahima15-Jan-09 19:35 
QuestionRe:Please can some one help me DataGridViewCombobox EditingControlShowing event Pin
sahahima19-Jan-09 0:41
sahahima19-Jan-09 0:41 
QuestionRe:Please can some one help me DataGridViewCombobox EditingControlShowing event Pin
sahahima19-Jan-09 0:42
sahahima19-Jan-09 0:42 
GeneralRe: DataGridViewCombobox EditingControlShowing event [modified] Pin
SandipKhillare13-Feb-09 23:15
SandipKhillare13-Feb-09 23:15 
AnswerRe: DataGridViewCombobox EditingControlShowing event Pin
Arjun.nk17-Jan-18 23:12
Arjun.nk17-Jan-18 23:12 
QuestionHow to play sound in VB6 Pin
C#Coudou14-Jan-09 15:55
C#Coudou14-Jan-09 15:55 
AnswerRe: How to play sound in VB6 Pin
N a v a n e e t h14-Jan-09 16:10
N a v a n e e t h14-Jan-09 16:10 
AnswerRe: How to play sound in VB6 Pin
Dave Kreskowiak15-Jan-09 4:19
mveDave Kreskowiak15-Jan-09 4:19 
QuestionFax Automation Pin
arisam14-Jan-09 7:40
arisam14-Jan-09 7:40 
QuestionNeed Help! Pin
ShayanTanwir14-Jan-09 7:07
ShayanTanwir14-Jan-09 7:07 
AnswerRe: Need Help! Pin
EliottA14-Jan-09 7:20
EliottA14-Jan-09 7:20 
AnswerRe: Need Help! Pin
Jon_Boy14-Jan-09 7:25
Jon_Boy14-Jan-09 7:25 
AnswerRe: Need Help! Pin
Henry Minute14-Jan-09 13:35
Henry Minute14-Jan-09 13:35 
QuestionVideo.ShowCursor...Is it possible to show the cursor in fullscreen mode using dX.AudioVideoPlayback? Pin
rspercy6514-Jan-09 7:02
rspercy6514-Jan-09 7:02 
QuestionSystem.AccessViolationException from external DLL Pin
Anita Fourie14-Jan-09 1:03
Anita Fourie14-Jan-09 1:03 
AnswerRe: System.AccessViolationException from external DLL Pin
Tom Deketelaere14-Jan-09 1:27
professionalTom Deketelaere14-Jan-09 1:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.