الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

Fill combobox

مغلق
بدأه Moolly Doolly في 3 ديسمبر 2005 · 12 رد · 1,420 مشاهدة · في Microsoft Visual Basic.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

I need to fill combobox named crs with all the Courses

that already in Data Base table"Course" Column "crs_code"

:(

that how i thought it done

but it did'nt work

:(

 Dim _oCon As New System.Data.SqlClient.SqlConnection()
        _oCon.ConnectionString = "server=(local);database=collage;trusted_connection=yes"
        Dim s As String
        s = "select Crs_code from Course "
        Dim adpt As New System.Data.SqlClient.SqlDataAdapter(s, _oCon)
        Dim DS As New DataSet()
       adpt.Fill(DS)
        crs.DataSource = DS.Tables(0).Columns(0)

Please if any one no how to do it ,please tell me :(

#2

اعتقد ألمفروض تكتب

crs.DataSource = DS.Tables(0)

crs.displaymember = DS.Tables(0).Columns(0)

يعني انت حاط ان مصدر البيانات هو عمود والمفروض يكون اسم جدول

انا ماجربت الكود بس اتوقع كذا والله اعلم

<span style='color:green'>سؤل ابن عباس عن علمه كيف جمعه فقال :( أوتيت لسانا سؤولا وقلبا عقولا)</span>

#3

Thank U :rolleyes:

But it did'nt work :(

crs.DataSource = DS.Tables(0)

crs.displaymember = DS.Tables(0).Columns(0) 'Cannot be converted to string

#4

hi

crs.displaymember =name of the field as text

desplay memmber take string

crs.displaymember="crs_code"

#5

هذا التعديل

CobBox.DataSource = MyDataSet.Tables(0)

CobBox.DisplayMember = MyDataSet.Tables(0).Columns(1).ColumnName

CobBox.ValueMember = MyDataSet.Tables(0).Columns(0).ColumnName

<span style='color:green'>سؤل ابن عباس عن علمه كيف جمعه فقال :( أوتيت لسانا سؤولا وقلبا عقولا)</span>

#6

,Hi

Thank U

But :( ti still didn't work i don't know Y

this is my code againe if U found some thing wrong tell me ,please

:(

Private Sub crs_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 
        Dim _oCon As New System.Data.SqlClient.SqlConnection()
        _oCon.ConnectionString = "server=(local);database=Colage;trusted_connection=yes"
        Dim s As String
        s = "select * from Course "
        Dim adpt As New System.Data.SqlClient.SqlDataAdapter(s, _oCon)
        Dim DS As New DataSet()
        adpt.Fill(DS)
        crs.DataSource = DS.Tables(0)
        crs.DisplayMember = "crs_code"
End Sub

:(

when i but it in the form load the list in run is became like this:

System.Data.DataRowView

and then i but it in the same combobox Sub but it show me nothing

Can any one help me, please

:unsure:

#7

Still with that it didn't work

Crs.DisplayMember = DS.Tables(0).Columns(1).ColumnName

Crs.ValueMember =DS.Tables(0).Columns(0).ColumnName

It make me crazy

:wacko:

#8

hi try to add thats inthe last record in the the code

crs.DisplayMember = "crs_code"

crs.ValueMemeber= "crs_code"

try and tell me

#9

Still in the run it show me nothing

may be the place the header i but the code in

i don't know

it the first tme for me to code with VB.NET

#10

إستخدمي أداة التحويل ToString بهذا الشكل

crs.displaymember = DS.Tables(0).Columns(0).ToString

و إن كان أفضل أن يوضع اسم العامود يسبقه اسم الجدول مباشرتاً بين علامتي التنصيص

cboxNationality.DisplayMember = "Nationality.Nationality"

بالتوفيق إن شاء الله.

في المثال يتضح المقال

#11

Yes' it work

Thank U :rolleyes:

i wrote it in the form load and it did work

and thanks to all who help me

Soooooooooo Much

i know i bother u I'm clumsy some times

:rolleyes:

#12

اخي الكريم هل ممكن ان نعرف الخطأ في اكوادنا وما الكود الصح الذي اشتغل معاك

للمعرفة فقط

<span style='color:green'>سؤل ابن عباس عن علمه كيف جمعه فقال :( أوتيت لسانا سؤولا وقلبا عقولا)</span>

#13

This is the one that works with me

crs.DataSource = DS.Tables(0)

crs.DisplayMember = "Section.crs_code"

crs.ValueMember = "crs_code"

and i had to but it in the form load

Thanks to U all B)

هذا الموضوع مغلق.

مواضيع مشابهة