billy_bob169 Posted January 30, 2003 Posted January 30, 2003 I built a simple project in VB6, and I loaded a Flex Grid control using a loop and some simple formulas based on the users input. I have been trying to build the same project in VB.Net, but have yet to find a way to load a grid. I don't want the grid to be tied to a database, I just want to load it the way I did before. Is there any way to do this? I really don't want to be using COM objects, and I am trying to get away from them!! Someone please help if you can...:( Quote I'd rather be riding than working
*Gurus* divil Posted January 30, 2003 *Gurus* Posted January 30, 2003 You can bind a datagrid to a disconnected dataset I think, but I haven't actually done this myself. Searching Google with those keywords will probably help you. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
billy_bob169 Posted January 30, 2003 Author Posted January 30, 2003 Doesn't a dataset have to be initially linked to a database though? Also, is it possible to link a grid to an XML file? Quote I'd rather be riding than working
*Experts* Nerseus Posted January 31, 2003 *Experts* Posted January 31, 2003 You must bind your grid to a DataSet or something that supports IBindingList and maybe another interface or two. You definitely do not need a database to use a DataSet. You can load one a number of ways - completely manually if you wanted to. If you have valid XML you can load a DataSet using the ReadXml() method. If you use XmlReadMode.InferSchema it will build a schema for you... -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
billy_bob169 Posted January 31, 2003 Author Posted January 31, 2003 I'll give it a shot! Thanks... Quote I'd rather be riding than working
*Experts* Nerseus Posted January 31, 2003 *Experts* Posted January 31, 2003 I should have mentioned that to create an "unbound" DataSet you simply create it like any other object. You can add tables and columns pretty easily, too. For example: DataSet ds = new DataSet("MyDataSet"); DataTable dt = ds.Tables.Add("MyTable"); dt.Columns.Add("ID", typeof(Int32)); dt.Columns.Add("FirstName", typeof(string)); dt.Columns.Add("LastName", typeof(string)); dt.Columns.Add("DOB", typeof(DateTime)); DataRow row; // Add all values in one shot dt.Rows.Add(new object[] {1, "Dan", "Jones", new DateTime(1971, 11, 28)}); // Add all values in an array ArrayList a = new ArrayList(); a.Add(2); a.Add("Carl"); a.Add("Jones"); a.Add(new DateTime(2001, 11, 1)); dt.Rows.Add(a.ToArray()); // OR Add explicitly (my favorite) row = dt.NewRow(); row["ID"] = 3; row["FirstName"] = "Bob"; row["LastName"] = "Jones"; row["DOB"] = new DateTime(2000, 1, 1); dt.Rows.Add(row); // Show the results Debug.WriteLine(ds.GetXml()); -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
billy_bob169 Posted January 31, 2003 Author Posted January 31, 2003 Thanks a ton for your help. The example code you included helps clear up a lot of questions I had. This forum is really a great help for people like myself, struggling to learn .Net. I'll let you know what I figure out. Quote I'd rather be riding than working
billy_bob169 Posted January 31, 2003 Author Posted January 31, 2003 I got it to work!!! Even better than the old FlexGrid way. Thanks again Divil and Nerseus Quote I'd rather be riding than working
*Experts* Nerseus Posted January 31, 2003 *Experts* Posted January 31, 2003 Wait til he figures out the Relationships property of the DataSet and hierarchical datasets/grids :) -nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.