"How Do I" Videos - Here's What's Next!

Published 24 May 07 11:52 AM

Based on all the great (and numerous) amounts of positive feedback on the first series of videos, I'm ramping up to start the next wave. I took into account each and every request I got and came up with the following areas of focus - all related to what you can do now with VS 2005:

Object Binding  
Reporting & Printing
Managing Database Changes
Deployment
Interop Forms
Validation

These areas will span at least 10 videos that I'm shooting to have done by mid-June so stay tuned! And once again, keep the feedback coming!

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Pram said on May 25, 2007 12:38 PM:

Great, can not wait till those done. Hope that there are C# version too, like always.

# Beth Massi said on May 25, 2007 2:01 PM:

Hi Pram,

These videos will all be in Visual Basic, but I'll forward your request to the C# team.

-B

# tw said on May 25, 2007 4:25 PM:

I have been eagerly looking forward to the one on Object Binding!  Enough so I believe it has made a few people jealous  ;)

# pmmci said on May 26, 2007 7:34 AM:

I've seen some of your videos. They're good.

I'm new to VB. How do you create codesnippets. e.g. DeleteCustomer

# Bob said on May 28, 2007 5:25 AM:

Using Typed DataSets are great,but we need information on how to create encoded connection strings so someone can't read them in the app.config file. How about a video on doing that?

# Jerry said on May 29, 2007 7:56 AM:

Your videos are the best!

I can't wait to see the next set of videos!

I've just started working with SQL 2005, who would have thought data could be so much fun! :)

I would like to see a video, of populating a TreeView in a win form application with a SQL 2005 database.

Do you have any info to get me pointed in the right direction.

How would I bind the specific columns to the correct nodes?

Thanks again.

# Jerry said on May 29, 2007 7:57 AM:

Your videos are the best!

I can't wait to see the next set of videos!

I've just started working with SQL 2005, who would have thought data could be so much fun! :)

I would like to see a video, of populating a TreeView in a win form application with a SQL 2005 database.

Do you have any info to get me pointed in the right direction.

How would I bind the specific columns to the correct nodes?

Thanks again.

# Beth Massi said on May 29, 2007 9:27 PM:

Hi pmmci,

You can create code snippets by selecting text in the code editor and then dragging that onto the toolbox. Then you can use that snippet of code again by dragging from the toolbox into the editor.

-B

# Beth Massi said on May 29, 2007 9:35 PM:

Hi Jerry,

Binding with a TreeView is not automatic since this control does not have a DataSource property and the treeview is a hierarchical representation of data and not just a flat list. You have to create the nodes manually by looping through your DataViews. I will try to post a sample scenario on this blog. :-)

-B

# Jerry said on May 29, 2007 11:04 PM:

Thanks Beth.

I've been serching for a while on how to bind the data to a treeview (VB.net/SQL 2005).

I appreciate any help.

I look forward to all the great info you post on this blog.

Thanks again. :)

# Jerry said on June 1, 2007 5:22 PM:

Well I've been working on getting the treeview populated with my data.

I can get the TableName & ColumnName into the TreeView, after that I'm stuck :(

Any ideas? (sorry I'm impatient) :)

I'm not sure I'm going in the right direction, here is what I have so far.

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim dt As DataTable

       Dim dc As DataColumn

       Dim NTables, NTable, NColumn As TreeNode

       Try

           TreeView1.BeginUpdate()

           TreeView1.ShowLines = True

           TreeView1.ShowPlusMinus = True

           TreeView1.ShowRootLines = True

           TreeView1.HideSelection = False

           TreeView1.HotTracking = True

           NTables = New TreeNode("Library Info")

           NTables.ForeColor = Color.Blue

           TreeView1.Nodes.Add(NTables)

           For Each dt In CustomerOrdersDataSet.Tables

               NTable = New TreeNode(dt.TableName)

               NTable.ForeColor = Color.Red

               NTables.Nodes.Add(NTable)

               For Each dc In dt.Columns

                   NColumn = New TreeNode(dc.ColumnName)

                   NColumn.ForeColor = Color.Green

                   NTable.Nodes.Add(NColumn)

               Next

           Next

       Catch ex As Exception

           MessageBox.Show(ex.ToString)

       Finally

           TreeView1.ExpandAll()

           TreeView1.EndUpdate()

       End Try

End Sub

# Beth Massi said on June 1, 2007 6:23 PM:

Hi Jerry,

You'll need to add a For..Each for the DataRows too in there. Something like:

For Each dc In dt.Columns

   NColumn = New TreeNode(dc.ColumnName)

   NColumn.ForeColor = Color.Green

   NTable.Nodes.Add(NColumn)

   For Each dr As DataRow In dt.Rows

       Dim val As Object = dr(dc)

       If IsDBNull(val) Then

           val = "<null>"

       End If

       Dim nRow As New TreeNode(val.ToString)

       NColumn.Nodes.Add(nRow)

   Next

Next

# Tom said on June 2, 2007 12:25 PM:

Hi Beth,

Super job on the videos.  You get 5 stars from me.

Your boss should give you a higher salary for this work!  Truely, we cannot use the great features of a product if we do not know how to use them.  MS has tons of written documentation, but who has time to read it? (Not me)

Suggested video: Project wide Exception handling.

The Try-Catch blocks are great, but there is sometimes that unanticipated error.  How can we provide Exception handling that will encompass the entire project to catch unanticipated errors?

Keep up the good work!

Tom

# Jerry said on June 4, 2007 8:27 PM:

Beth,

Thank you so much!

Your code worked GREAT! :)

I'll post the final code, & hope it can help anyone else looking to add a TreeView to their project.

If anyone wants to add this code, what I did was add a TreeView "AFTER" I finished the "3OneToManyForm" Video by Beth Massi.

Thanks again  :)

--------------------------------------------------------------------------------------------------------------------------

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

       'TODO: This line of code loads data into the 'CustomerOrdersDataSet.Orders' table. You can move, or remove it, as needed.

       Me.OrdersTableAdapter.Fill(Me.CustomerOrdersDataSet.Orders)

       'TODO: This line of code loads data into the 'CustomerOrdersDataSet.Customer' table. You can move, or remove it, as needed.

       Me.CustomerTableAdapter.Fill(Me.CustomerOrdersDataSet.Customer)

       'Me.CustomerTableAdapter.Fill(Me.CustomerOrdersDataSet.Customer)

       'Me.TreeView1.Nodes.Add(New CategoryTreeNode())

       'Me.CustomerTableAdapter.Fill(Me.CustomerOrdersDataSet.Customer)

       'TreeView1.BeginUpdate()

       'TreeView1.Nodes.Add("Parent")

       'TreeView1.Nodes(0).Nodes.Add("Child 1")

       'TreeView1.Nodes(0).Nodes.Add("Child 2")

       'TreeView1.Nodes(0).Nodes(1).Nodes.Add("Grandchild")

       'TreeView1.Nodes(0).Nodes(1).Nodes(0).Nodes.Add("Great Grandchild")

       'TreeView1.EndUpdate()

       ' ''TreeView1.BeginUpdate()

       ' ''TreeView1.Nodes.Add(Me.CustomerTableAdapter.Fill(Me.CustomerOrdersDataSet.Customer))

       ' ''TreeView1.Nodes.Add(Me.OrdersTableAdapter.Update(Me.CustomerOrdersDataSet.Orders))

       ' ''TreeView1.Nodes(0).Nodes.Add(Me.OrdersTableAdapter.Update(Me.CustomerOrdersDataSet.Orders))

       ' ''Me.TreeView1.Nodes.Add(Me.OrdersTableAdapter.Fill(Me.CustomerOrdersDataSet.Orders))

       ' ''Me.TreeView1.Nodes.Add(Me.CustomerTableAdapter.Update(Me.CustomerOrdersDataSet.Customer))

       ' ''TreeView1.EndUpdate()

       ' ''TreeView1.ExpandAll()

       'Me.TreeView1.ExpandAll()

       ' ''InfoDataset123(TreeView1, CustomerOrdersDataSet, True)

       Dim dt As DataTable

       Dim dc As DataColumn

       Dim NTables, NTable, NColumn As TreeNode

       Try

           TreeView1.BeginUpdate()

           TreeView1.ShowLines = True

           TreeView1.ShowPlusMinus = True

           TreeView1.ShowRootLines = True

           TreeView1.HideSelection = False

           TreeView1.HotTracking = True

           NTables = New TreeNode("Library Info")

           NTables.ForeColor = Color.Blue

           TreeView1.Nodes.Add(NTables)

           For Each dt In CustomerOrdersDataSet.Tables

               NTable = New TreeNode(dt.TableName)

               NTable.ForeColor = Color.Red

               NTables.Nodes.Add(NTable)

               For Each dc In dt.Columns

                   NColumn = New TreeNode(dc.ColumnName)

                   NColumn.ForeColor = Color.Green

                   NTable.Nodes.Add(NColumn)

                   'For Each dr As DataRow In dt.Rows

                   For Each dr As DataRow In dt.Rows

                       Dim val As Object = dr(dc)

                       If IsDBNull(val) Then

                           val = "<null>"

                       End If

                       Dim nRow As New TreeNode(val.ToString)

                       NColumn.Nodes.Add(nRow)

                   Next

               Next

           Next

       Catch ex As Exception

           MessageBox.Show(ex.ToString)

       Finally

           'TreeView1.ExpandAll()

           TreeView1.EndUpdate()

       End Try

   End Sub

# Sabbir said on June 8, 2007 11:47 AM:

Your the best!!!  Thank you for the excellent video!

# Dustin Townsend said on June 13, 2007 7:27 AM:

Beth,

I'd like to see some videos on dynamic typing with Visual Basic.net.

One problem I am having now is generating a group of panels with a different color for each one and placing each panel in an autosized table layout panel all dynamically.  The intent is to allow the user to later update the colors if needed.

I'd like to learn how to use dynamic programming through out my entire program, so that basically everything could be easily changed by the end user and easily set-up by our team for the end user - instead of me doing custom programming for each end user.

# Bob said on June 15, 2007 2:51 PM:

Hi Beth,

Nice work; very thorough.

What software do you use to create these videos?

Best regards,

Bob

bobishkindaguy@hotmail.com

# Moh. said on June 18, 2007 5:57 AM:

i hope not to die befor i see you next video.

# Beth Massi said on July 13, 2007 7:09 PM:

Hi Bob,

I use Camtasia by TechSmith.

Cheers,

-B

# Beth Massi said on July 13, 2007 7:10 PM:

Hi Dustin,

I have a note here to create a blog post on exactly what you're trying to accomplish. I'll try and post early next week. :-)

Thanks for reading,

-Beth

# Beth Massi said on July 13, 2007 7:15 PM:

Tony,

I'm not quite sure what the easiest control would be here is you wanted to allow editing. With the DataGridView, you could set it up to display that way by creating the three rows (already aggragated) that had columns:

Type, Year2007, Year2006, Year2005

and then filled the rows with:

"Assets", xxxx, xxxx, xxxx

"Liability", xxxx, xxxx, xxxx

"Equity", xxxx, xxxx, xxxx

You could probably create a database view that aggregated the data first and then you could create a DataSet vased on the database view and then bind that to your DataGridView.

The other way to do it is to use the ReportViewer and create a report. I have a video on the ReportViewer here: http://msdn2.microsoft.com/en-us/vbasic/bb643819

HTH,

-Beth

# Beth Massi said on July 18, 2007 1:47 AM:

Dustin,

Check out this post: http://blogs.msdn.com/bethmassi/archive/2007/07/17/an-example-of-dynamic-programming-in-vb.aspx

HTH,

-B

# Bob said on July 31, 2007 8:15 PM:

Hi Beth,

Thanks for the many-to-many example. Exactly what I needed.

Of course, there is one more thing....  :-)

I'm using a many-to-many to build a Sales Prospects database. A prospect may belong to more than one Organization, and of course an organization may have more than one Prospect to track.

So, I need to add this ability to show Orgs parent, and view the Prospects in the Org, exactly as your example showed. But what is the best way to enable the user to add a prospect to the Org?

Of course, the bottom datagridview lets you add a row, but the row disappears when you click off it, because what was really needed was a row to be added at the same time to the "middle" table.

I know, I know, not a simple request.

Thanks, Beth

Bob

bobishkindaguy@hotmail.com

# Steve Naumann said on August 1, 2007 11:51 AM:

I really liked the Forms over Data videos, very nice.  I learned tons!  The MS documentation just doesn't spell it out like your videos do.  

The one question I had through the whole thing is how to apply this information to tables that may have thousands or even tens of thousands of rows.  The default Fill command, as everyone knows, fills the DataTables with all the data from the table.  This obviously has to be modified to work with large tables.  I have created DataSets with my own Fill commands that limit the data, but I was wondering if there was something built-in to deal with this problem.  I can't find any documentation on how MS recommends tackling this problem and I haven't found any examples on the internet.  I just can't figure out why it seems as if nothing is there in VS to help.  My own techniques work but they require monotonous coding that would be nicer if it was part of the automated code-writing IDE.  I don't think I should try to create a wizard myself to do this coding if I am missing something built-in to VS.  How would you do this?

# Beth Massi said on August 1, 2007 12:17 PM:

Hi Steve,

Take a look at this article: http://blogs.msdn.com/bethmassi/archive/2007/05/25/creating-a-parameterized-query.aspx

This explains how to add parameterized queries to your TableAdapters that you can call to limit the data that is filled. If you take a look at video #4 here http://msdn2.microsoft.com/en-us/vbasic/bb643828.aspx it shows another technique on how to add a parameterized query to your TableAdapter. You can call this query from anywhere on your form though, you're not limited to using it on a DataGridView.

Also you can take a look at the sample application that is attached to this post: http://blogs.msdn.com/bethmassi/archive/2007/07/11/tableadapters-and-transactions.aspx

Hope this helps.

-B

# Steve Naumann said on August 1, 2007 2:56 PM:

I see now I am on the right track.  The technique I was using uses parameterized queries.  Its too bad using that technique involves a bunch of monotonous programming, but at least I know I'm not missing anything.  I think I'm understanding this now pretty well.

I'm adding custom Fill commands to the TableAdapter to perform the following custom functions:

FillFirst

FillNext

FillPrevious

FillLast

The FillNext and FillPrevious queries accept the current primary key as the parameter and get the next or previous record based from a Top 1 query with a sort.  All of my custom Fill queries return only one record into the DataTable (no need to load thousands.)  I then replace the default mechanism in the BindingNavigator that scrolls the BindingSource with custom click events that call the relevant Fill command and place the FindFirst in the Load event of the Form.  Works really nice and is very fast.

I'm going to keep going with this idea.

Thanks Beth!!

# Beth Massi said on August 1, 2007 4:06 PM:

Hi Steve,

Depending on your scalability needs that may not be the best way to design your UI. It's better to grab chunks of data than issuing many many queries that only return one row. You need to balance between calls to the database and the number of rows you return. Remember that a call to the database is an expensive operation because you are opening and closing connections everytime.

I would suggest providing a search mechanism that allows the user to select a set of rows and then work with those locally. That will probably get you the best balance.

HTH,

-Beth

# Chuck said on July 17, 2008 10:36 PM:

Could you please show me an example of populating a treeview from an arraylist. Thanks!

Leave a Comment

(required) 
(optional)
(required) 

  
Enter Code Here: Required

About Beth Massi

Beth is a Program Manager on the Visual Studio Community Team at Microsoft and is responsible for producing and managing content for business application developers, driving community features and team participation onto MSDN Developer Centers (http://msdn.com), and helping make Visual Studio one of the best developer tools in the world. She also produces regular content on her blog (http://blogs.msdn.com/bethmassi), Channel 9, and a variety of other developer sites and magazines. As a community champion and a long-time member of the Microsoft developer community she also helps with the San Francisco East Bay .NET user group and is a frequent speaker at various software development events. Before Microsoft, she was a Senior Architect at a health care software product company and a Microsoft Solutions Architect MVP. Over the last decade she has worked on distributed applications and frameworks, web and Windows-based applications using Microsoft development tools in a variety of businesses. She loves teaching, hiking, mountain biking, and driving really fast.

This Blog

Syndication

Page view tracker