Access data in datagridview from a class | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Access data in datagridview from a class

I'm trying to pass values from datagridview to a list. And then in a new class I want to make som methods accessing that list. Trouble is that when I pass the datagridview it returns it without content and values which means I can't do anything with it. any help is appreciated! see more information on link. http://stackoverflow.com/questions/42026708/access-data-in-datagridview-from-a-class/42026887?noredirect=1#comment71228293_42026887

5th Feb 2017, 5:46 PM
fredjac
fredjac - avatar
10 Answers
0
I don't remember the full path, but Globalization in System might be able to help. it should allow you to access other files in your code from there
5th Feb 2017, 8:35 PM
Phil Marinucci
Phil Marinucci - avatar
0
Are you sure this is a step in the right direction? From msdn documentation it seems that system.globalization contains classes for different regions, calendars etc.
5th Feb 2017, 10:22 PM
fredjac
fredjac - avatar
0
wait no, I'm wrong. add the form to the namespace. should be accessable then.
6th Feb 2017, 12:26 AM
Phil Marinucci
Phil Marinucci - avatar
0
the class and form see in the same namespace.
6th Feb 2017, 5:31 AM
fredjac
fredjac - avatar
0
they're both in the same name space? and you can't make an object for the class?
6th Feb 2017, 6:30 AM
Phil Marinucci
Phil Marinucci - avatar
0
they're both in the same namespace and I can't access values from datagridview (public partial class form1) from another class. let's say class MyClass.
6th Feb 2017, 7:32 AM
fredjac
fredjac - avatar
0
oh yeah, no. I'm pretty sure all its methods are protected. I don't think windows wants you editing the form dynamically.
6th Feb 2017, 6:13 PM
Phil Marinucci
Phil Marinucci - avatar
0
I probably found the solution here: https://social.msdn.microsoft.com/Forums/windows/en-US/a5e3b46e-8d45-4c45-a3d6-20a25b746825/accessing-form1-controls-from-a-different-class?forum=winforms I tried something similar at work today which worked for a simpler project I wrote to test, but that solution didn't functioned properly in my real project. I'll find out tomorrow an will let you know how it went.
6th Feb 2017, 6:17 PM
fredjac
fredjac - avatar
0
thanks. I'm curious.
6th Feb 2017, 6:18 PM
Phil Marinucci
Phil Marinucci - avatar
0
I can confirm that my last post was the solution. Great workday today 😁
7th Feb 2017, 7:39 PM
fredjac
fredjac - avatar