Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
iam using bulksms online software sir .. perfect sending messgess
but present iam using sms api to trying develop own windows vb.net application sir


I want to select classnames in checkbox after automatically add the mobile nos in mobiletextbox in vb.net

checkbox select jpg file

select checkbox jpg file link
[^]

VB.NET
Private Sub CheckedListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckedListBox1.SelectedIndexChanged

which code write in this sir   


End Sub




Hi sir,
Iam created student data

Class name & name & phone number
1st class – prabhakar – 9908302604
1st class – rajesh – 9999999999
2nd class – codeproject – 8888888888
3rd class – prasd – 8888888888

C#
Iam writed code in form load 

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

    End Sub

Sub classcheckbox1()
        Try

            Dim CN As New OleDbConnection(css)
            CN.Open()
            adp = New OleDbDataAdapter()
            adp.SelectCommand = New OleDbCommand("SELECT distinct RTRIM(chitgroupname) FROM caddingroup", CN)
            ds = New DataSet("ds")
            CheckedListBox1.Items.Clear()
            For Each drow As DataRow In dtable.Rows
                CheckedListBox1.Items.Add(drow(0).ToString())
            Next
            CN.Close()
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub


i want this changes after seelct checkbox:

If iam select 1st class add only 1st class phone numbers in mobiletextbox
If iam select all classess add all class phone numbers in mobiletextbox
Posted
Updated 26-Jan-16 2:24am
v7
Comments
Scribling Doodle 26-Jan-16 11:23am    
Please change the Tags from C# to vb.net because the code you're showing here is for visual basic and in c# i think you will not get the help you might want. Thanks in advance!

1 solution

First of all: if you want to allow the user to select more than one class from the CheckedListbox, you should use event SelectionChanged instead of SelectedIndexChanged, than read the currently selected class names from the SelectedItems collection. Next you create a new SQL command that filters out only those records containg one of the selected classes, e.g. SELECT * FROM table WHERE classname IN ('class1, 'class2'....and so on).

Get the resulting recordset and write the data from its records to your target textbox or wherever you need the data.
 
Share this answer
 
Comments
prabhakarcs 27-Jan-16 5:17am    
yes sir .. iam write SelectionChanged changed even
perfect cell1 numbers come in combo box next richtextbox 1

but how to get direct cell1 show in richtextbox1

without combo box use how cell1 numbers show in richtextbox1 sir..

Dim itemChecked As Object

a = ""

For Each itemChecked In CheckedListBox1.CheckedItems
a += "'" + itemChecked.ToString() + "',"

Next

Try

Dim con As New OleDbConnection(css)
con.Open()
adp = New OleDbDataAdapter()

adp.SelectCommand = New OleDbCommand("SELECT cell1 from caddingroup where chitgroupname IN (" & a & ")", con)

ds = New DataSet("ds")
adp.Fill(ds)
dtable = ds.Tables(0)
ComboBox1.Items.Clear()
For Each drow As DataRow In dtable.Rows
ComboBox1.Items.Add(drow(0).ToString())
Next

con.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try


Dim i As Long
For i = 0 To ComboBox1.Items.Count - 1
RichTextBox1.Text = RichTextBox1.Text + ComboBox1.Items(i).ToString & ","
Next


End If
NightWizzard 27-Jan-16 13:03pm    
Sorry, I don't understand what your problem is or what you want to do...?? And why you first add results to a combo and then from combo to Richtextbox? Why don't put the results directly to the Richtextbox?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900