Autor Beitrag
moori64
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 76



BeitragVerfasst: Do 24.11.11 17:47 
hallo,

ich wollte einer listbox daten übergeben und datacontext wir rot unterstrichen woran liegt das ?


uwe
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4796
Erhaltene Danke: 1059

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Do 24.11.11 20:59 
Hallo,

da scheinst du wohl ein Beispiel für WPF erwischt zu haben, denn unter WinForms heißt die Eigenschaft 'DataSource' ;-)
moori64 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 76



BeitragVerfasst: Fr 25.11.11 10:23 
guten morgen,

da hast du recht, ich habe mir ja das buch von galileo gekauft.
in den video von galileo ist bei link to sql die rede davon das man sich da eine klasse von erstellen kann.
mir fehlt aber dieser menüpunkt gänzlich. woran liegt das ?

viele grüße
uwe
ujr
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 102
Erhaltene Danke: 12



BeitragVerfasst: Fr 25.11.11 13:00 
user profile iconmoori64 hat folgendes geschrieben Zum zitierten Posting springen:
woran liegt das ?


Vermutlich daran, dass Deine Shift-Taste kaputt ist. Es heißt "DataContext".
moori64 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 76



BeitragVerfasst: Fr 25.11.11 13:15 
nein , es war schon richtig es lag an der version . die daten bekomme ich aber trotzdem nicht übergeben irgendwas fehlt da noch

kann ich überhaut eine komplette tabelle übergeben ?
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
                string connstr = @"data source=localhost\V2B;user id=sa;password=moori64;integrated security=false;"
              + "persist security info=false;initial catalog=v2b_sql";

            SqlConnection conn = new SqlConnection(connstr);

            conn.Open();

            SqlDataAdapter adap = new SqlDataAdapter("select  * from Mannschaft", conn);
            DataTable tab = new DataTable();
            adap.Fill(tab);

            listBox1.DataSource = tab;


Moderiert von user profile iconTh69: C#-Tags hinzugefügt
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4796
Erhaltene Danke: 1059

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Fr 25.11.11 13:25 
Hallo,

entweder mußt du noch die Eigenschaft "DisplayMember" auf den anzuzeigenden Spaltennamen setzen oder aber du nimmst ein DataGridView (mit AutoGenerateColumns = true).
lothi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 114
Erhaltene Danke: 3



BeitragVerfasst: Do 01.12.11 14:27 
Hallo

DataContext

Findest du im System.Data.Lynq.

Gruss Lothi