C
C#11mo ago
larva

unexpected problem in windows form

help
29 Replies
larva
larvaOP11mo ago
fillGenre(); comboBox1.DataSource = Genres; comboBox1.DisplayMember = "Genre Type"; genretype = Genres.Rows[comboBox1.SelectedIndex]["Genre Type"].ToString(); says an error at the displaymember line that genre type already exists but this is the first instance of it in this code
Pobiega
Pobiega11mo ago
Do you really have a property on your genre object called Genre Types (space included)? because DisplayMember should be the name of the member that contains the data you wish to display
larva
larvaOP11mo ago
hello pobiega my friend i fixed the issue i made a list in this class called book its called books
Pobiega
Pobiega11mo ago
great. then you can $close this thread
MODiX
MODiX11mo ago
Use the /close command to mark a forum thread as answered
larva
larvaOP11mo ago
i still have another problem so the list is called books its public static
Pobiega
Pobiega11mo ago
... static?
larva
larvaOP11mo ago
yeah
Pobiega
Pobiega11mo ago
that means its not related to the instance
larva
larvaOP11mo ago
there will only be 1 list for the book you understand me
Pobiega
Pobiega11mo ago
okay, so Book also has a list of books?
larva
larvaOP11mo ago
like there will only be 1 default list for the books book is the class
Pobiega
Pobiega11mo ago
yes.
larva
larvaOP11mo ago
inside the class i created a list of books
Pobiega
Pobiega11mo ago
and it has a static list of books?
larva
larvaOP11mo ago
yeah
Pobiega
Pobiega11mo ago
okay.
larva
larvaOP11mo ago
yes ok so now i want to be use books the list in other classes despite being public its not seen by other classes
Pobiega
Pobiega11mo ago
none of these screenshots show your issue show you trying to access the list from outside
larva
larvaOP11mo ago
it can see the class Book but not books
Pobiega
Pobiega11mo ago
... mate books is not automagically avaialble in the global scope you need to access it via its owning class
larva
larvaOP11mo ago
damn you became british yeah ik
Pobiega
Pobiega11mo ago
Book.books
larva
larvaOP11mo ago
i tried this first still nothing
Pobiega
Pobiega11mo ago
show me
larva
larvaOP11mo ago
its a list btw
Pobiega
Pobiega11mo ago
well yeah you're inside the class definition of another class you can't randomly write code anywhere you want you need to be inside a method or a body or something
larva
larvaOP11mo ago
oooh so just make a void method and do the code there thanks why couldnt i call books from the class definition i want to understand
Pobiega
Pobiega11mo ago
because.. its a class definition? like, you cant put code that DOES things there you put code that DECLARES members there like methods, properties, fields etc but you cant randomly put a method call, member access (thats what you tried) or a for loop there, for example
Want results from more Discord servers?
Add your server