在Visual Basic中寻找WPF数据网格信息 [英] Looking for WPF datagrid information in Visual Basic

查看:87
本文介绍了在Visual Basic中寻找WPF数据网格信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自1997年退休以来,我一直致力于研究和出版材料以及网站www.bobagans.org,这就是我的职业.我的第二个追求是在通用计算领域,最终确定我希望主修的特定计算领域,这就是我的爱好.

我现在的网站是我于2008年1月5日在71岁时创建的第三个网站.我使用的软件是Microsoft的2005、2008,现在是VS 2010 Express ASP.NET4.
使用的主要书籍:
1.由荷兰的Imar Spaanjaars撰写的C#和VB中的ASP.NET 4入门,由Wrox出版于2010年出版.我发现这本书是最能说明计算机网络设计基础知识的书.
2.由Bill Even,Scott Hansel man和Devin Rader撰写的C#和VB专业ASP.NET 4,也是2010 Wrox出版物.这本书的内容也非常丰富,超出了我的能力范围,并且可能包含了我永远不会感兴趣的内容.

关于我的计算机爱好,我的兴趣仅限于Microsoft的VS 2010 Express Visual Basic和.NET 4,其中包含并包含其他几个平台.我正在使用并希望更深入地学习的平台是Windows Presentation Foundation(WPF),实体框架(EF)和Visual Basic(VB).我特别喜欢并喜欢可扩展应用程序标记语言(XAML).
使用的主要书籍:
1.《 Visual Basic 2005-程序员参考》,作者:Rod Stephens,2005年Wrox出版.
2.由几位作者以及Wrox 2010出版物组成的Professional Visual Basic 2010和.NET4.
3. 2010年Apress出版物Matthew MacDonald编写的.NET 4 VB 2010中的Pro WPF.

我阅读的这些以及其他书籍和出版物解释说WPF是执行Windows应用程序的一种新方法,前一种方法是使用Windows Forms(我一直使用到2010年).虽然WPF具有更大的潜力,但它也有很大的潜力很难学习.另外,由于它太新了,因此关于如何完成我过去使用Windows窗体所做的某些工作的信息也很匮乏.在过去的一年中,我搜索了书店和互联网,但是收效甚微,因为我要查找的特定信息是如何将WPF数据网格编辑,保存和更新到数据库,然后获取要用于计算的单个单元格数据用于更新其他数据表.下面的段落将使您了解为什么我要寻找这些特殊功能.我不是开发人员或熟练的程序员,而是喜欢在这些平台上工作的人. 您能在WPF数据网格上建议一个简单易用的Visual Basic信息源来实现这些目标吗?

从大约1984年直到工厂关闭,直到1997年12月,我在办公室工作,担任加利福尼亚州洛克福德市ParaFab工程公司的业务和工程管理员,在那里我开发了一个Dos Paradox3商业应用程序,该应用程序可以处理办公室中的所有内容,但不包括机械制造.图纸.工资单,购买和销售,工作记录和报告以及两个清单都是该应用程序的一部分.我于1998年退休,不久之后便开始更新ParaFab业务应用程序. Windows版Paradox5,仅出于个人目的. 2004年,我意识到并开始使用VB 2005 Express来继续关注更新同一业务应用程序的某些功能;从那时起,我已经在Web和商业应用程序中使用了每个新的Express版本.现在,我正在尝试将一些业务应用程序功能更新为WPF.

最新更新:

我想我已经找到了我需要回答的问题,这本书是我以前在这里发布的:朱莉娅·勒曼(Julia Lerman)的书,编程实体框架 – 2010年第二版.我得出的结论是,在继续使用WPF datagrid之前,我需要更全面地学习EF.

2011/3/19
我对朱莉的书编程实体框架误解了;其中的代码大部分是用C#编写的,而在Visual Basic中却很少.但这确实说明了Entity Framework的复杂性,使我几乎没有希望能够找到需要编辑的信息,找到并使用单个单元格信息,然后使用Visual Basic中的WPF datagrid更新数据库. />
2011年5月14日
我已从Entity Framework切换到LINQ,再转而使用SQL来与WPF DataGrid和应用程序一起使用,因此,我能够继续开发自己正在使用的应用程序.我不是尝试通过VB代码获取单个单元格的内容,而是使用查询,数组或队列来获取和安排内容;这对我来说很好,所以我可能不需要我首先要求的信息.

以下是构建客户发票的VB代码的典型示例:

Since retiring in 1997 I have concentrated upon researching and publishing material and a website at www.bobagans.org , this I call this my vocation. My second pursuit has been in the area of general computing to eventually decide what particular segment of computing I wished to major upon, this I call my hobby.

My present website is my third one that I started on January 5, 2008 at the age of seventy-one. The software that I have used is Microsoft’s 2005, 2008, and now VS 2010 Express ASP.NET 4.
Primary books used:
1. Beginning ASP.NET 4 in C# and VB, by Imar Spaanjaars from the Netherlands, and published by Wrox publishing in 2010. I have found this book to be the one that best explained the basics of computer web design.
2. Professional ASP.NET 4 in C# and VB, by Bill Even, Scott Hansel man, and Devin Rader, also a 2010 Wrox publication. This book, also very informative is quite a bit beyond my ability and probably includes things I will never be interested in.

Concerning my computer hobby, I have narrowed my interests to Microsoft’s VS 2010 Express Visual Basic and .NET 4, which contains and embraces several other platforms. The platforms I am using and wish to learn more thoroughly are Windows Presentation Foundation (WPF), Entity Framework (EF) and Visual Basic (VB); I especially like and enjoy Extensible Application Markup Language (XAML).
Primary books used:
1. Visual Basic 2005 - Programmer’s Reference, by Rod Stephens, a 2005 Wrox publication.
2. Professional Visual Basic 2010 and .NET 4, by several authors and also a Wrox 2010 publication.
3. Pro WPF in VB 2010 in .NET 4, by Matthew MacDonald, a 2010 Apress publication.

These and other books and publications that I have read explained that WPF was a new way of doing Windows Applications, the former way was by using Windows Forms, which I had used until 2010. While WPF has a much greater potential, it is also much harder to learn. Also, because it is so new, there is a shortage of information on how to do some of what I have in the past done with Windows Forms. Over the past year I have searched the book stores and the internet without much success, because the specific information I am looking for is how to edit, save and update to the database the WPF datagrid, and then get individual cell data to use in calculations for updating other data tables. The paragraph below will give you an idea of why I am looking for these particular features. I am not a developer or skilled programmer, merely someone who enjoys working with these platforms. Can you suggest a good and simple source of Visual Basic information on the WPF datagrid to accomplish these goals?

From about 1984 until the plant closed down in Dec. of 1997 I worked in the office as Business and Engineering Administrator for ParaFab Engineering in Lockeford CA., where I developed a Dos Paradox3 business application that handled everything in the office but the making of mechanical drawings. Payroll, purchases and sales, job records and reports and two inventories were all part of this application. I retired in 1998 and soon after began updating the ParaFab business app. to Paradox5 for Windows, just for my own personal enjoyment. In 2004 I became aware of and began to use VB 2005 Express to continue my interest in updating some of this same business application’s functions; since then I have used each new Express edition, both for the web and for the business app. Now I am trying to update some of my business applications functions to WPF.

Latest update:

I think I have found the book I need to answer the questions I previously posted here: Julia Lerman’s book, Programming Entity Framework – the 2010 second edition. I have come to the conclusion that I need to learn EF more thoroughly before I can proceed with WPF datagrid.

3/19/2011
I was misinformed about Julie’s book, Programming Entity Framework; the code in it is mostly written in C# with very little in Visual Basic. But it does illustrate the complexity of Entity Framework, and leaves me with little hope that I will be able to find the information I need to edit, find and use individual cell information and then update the database using WPF datagrid in Visual Basic.

5/14/2011
I have switched from Entity Framework to LINQ to SQL to work with my WPF DataGrids and applications, as a result I have been able to go forward with the app''s I am working on. Instead of trying to get individual cell contents through VB code, I''m using queries and arrays or queues to get and arrange the contents; this is working well for me, so I will probably not need the information I first requested.

Here is a typical example of the VB code behind to build a customer invoice:

<pre lang="vb">Private Sub btnWriteInvoice_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnWriteInvoice.Click<br />
        ''Me.spInvoice.ClearValue()  ''how can I start over every time through?<br />
        ''Create TextBlocks for StackPanal spInvoice<br />
        Dim TextBlock48 = New TextBlock()<br />
        TextBlock48.VerticalAlignment = Windows.VerticalAlignment.Top<br />
        TextBlock48.HorizontalAlignment = Windows.HorizontalAlignment.Center<br />
        TextBlock48.Text = "NorthWind Food Specialists"<br />
<br />
        Dim TextBlock49 = New TextBlock()<br />
        TextBlock49.Margin = New Thickness(0, 0, 0, 15)<br />
        TextBlock49.VerticalAlignment = Windows.VerticalAlignment.Top<br />
        TextBlock49.HorizontalAlignment = Windows.HorizontalAlignment.Center<br />
        TextBlock49.Text = Today<br />
<br />
        ''Get Purchase order number<br />
        Dim strOID As String = ""<br />
        strOID = TextBox1.Text<br />
        ''strOID = DataGrid2.Items.CurrentItem.ToString()    ''gets the whole first row, always<br />
        ''strRow = DataGrid2.Items.GetItemAt(strOID).ToString  ''gets the row of the number that I put in TextBox1<br />
        ''strRow = DataGrid2.Items.CurrentPosition.ToString()    ''always gets "0"<br />
        ''strIndexNum = DataGrid2.CurrentItem.ToString() ''throws an exception<br />
<br />
        ''Entity join query to get each item in the Order_Details table<br />
        Dim detailShow = From qi In db.Order_Details<br />
                         Join pro In db.Products On qi.ProductID Equals pro.ProductID<br />
                         Where qi.OrderID = strOID<br />
                         Select qi.OrderID, qi.ProductID, pro.ProductName, qi.Quantity, qi.UnitPrice<br />
<br />
        Me.DataGrid1.ItemsSource = detailShow<br />
<br />
        Dim quan = From q In detailShow<br />
                   Select q.Quantity<br />
<br />
        '' Creates and initializes a new Queue to store in an array or Queue the Quan.<br />
        Dim lops As Integer = 0<br />
        Dim lop2 As Integer = 1<br />
        Dim myQ As New Queue()<br />
        For Each q In quan<br />
            myQ.Enqueue(q)    ''Adds each item quanity to an array or Queue<br />
            lops = lops + 1<br />
        Next<br />
<br />
        Dim name = From n In detailShow<br />
                   Select n.ProductName<br />
<br />
        '' Creates and initializes a new Queue to store in an array or Queue the Name of the Product.<br />
        lops = 0<br />
        lop2 = 1<br />
        Dim myQ2 As New Queue()<br />
        For Each n In name<br />
            myQ2.Enqueue(n)    ''Adds each item name to an array or Queue<br />
            lops = lops + 1<br />
        Next<br />
<br />
        Dim cost = From c In detailShow<br />
                   Select c.UnitPrice<br />
<br />
        '' Creates and initializes a new Queue to store in an array or Queue the Cost of the Product.<br />
        lops = 0<br />
        lop2 = 1<br />
        Dim myQ3 As New Queue()<br />
        For Each c In cost<br />
            myQ3.Enqueue(c)    ''Adds each item cost to an array or Queue<br />
            lops = lops + 1<br />
        Next<br />
<br />
        ''Stores the array elements into variables<br />
        Dim strNam As String = "Hello"<br />
        Dim intQuan As Integer = 1<br />
        Dim sngCost As Single = 1.1<br />
        Dim TotalCost As Single = 1.1<br />
        Dim TotalCost2 As Single = 0<br />
        Dim txtBlock As String = "Put together"<br />
<br />
        Dim TextBox11 = New TextBox()<br />
        TextBox11.Width = 0<br />
        TextBox11.Height = 0<br />
<br />
        Dim cusName As String = TextBox2.Text<br />
        Dim TextBox10 = New TextBox()<br />
        TextBox10.Width = 0<br />
        TextBox10.Height = 0<br />
<br />
        Dim TextBlock50 = New TextBlock()<br />
        TextBlock50.Margin = New Thickness(0, 0, 40, 0)<br />
        TextBlock50.VerticalAlignment = Windows.VerticalAlignment.Top<br />
        TextBlock50.HorizontalAlignment = Windows.HorizontalAlignment.Right<br />
<br />
        Dim TextBlock51 = New TextBlock()<br />
        TextBlock51.Margin = New Thickness(0, 0, 40, 0)<br />
        TextBlock51.HorizontalAlignment = Windows.HorizontalAlignment.Right<br />
<br />
        Dim TextBlock52 = New TextBlock()<br />
        TextBlock52.Margin = New Thickness(0, 0, 40, 0)<br />
        TextBlock52.HorizontalAlignment = Windows.HorizontalAlignment.Right<br />
<br />
        Dim TextBlock53 = New TextBlock()<br />
        TextBlock53.Margin = New Thickness(0, 0, 40, 0)<br />
        TextBlock53.HorizontalAlignment = Windows.HorizontalAlignment.Right<br />
<br />
        Dim TextBlock54 = New TextBlock()<br />
        TextBlock54.Margin = New Thickness(0, 0, 40, 0)<br />
        TextBlock54.HorizontalAlignment = Windows.HorizontalAlignment.Right<br />
<br />
        Dim TextBlock55 = New TextBlock()<br />
        TextBlock55.Margin = New Thickness(0, 0, 40, 0)<br />
        TextBlock55.HorizontalAlignment = Windows.HorizontalAlignment.Right<br />
<br />
        Dim TextBlock56 = New TextBlock()<br />
        TextBlock56.Margin = New Thickness(0, 0, 40, 0)<br />
        TextBlock56.HorizontalAlignment = Windows.HorizontalAlignment.Right<br />
<br />
        Dim TextBlock57 = New TextBlock()<br />
        TextBlock57.Margin = New Thickness(0, 0, 40, 0)<br />
        TextBlock57.HorizontalAlignment = Windows.HorizontalAlignment.Right<br />
<br />
        ''Unites the variables into a textblock<br />
        For i = 1 To lops<br />
            intQuan = myQ.Dequeue<br />
            strNam = myQ2.Dequeue<br />
            sngCost = myQ3.Dequeue<br />
            TotalCost = intQuan * sngCost<br />
            TextBox11.Text = TotalCost<br />
            TextBox11.Text = Format(TotalCost, "$###0.00")<br />
            TotalCost2 += TotalCost<br />
            txtBlock = strNam & "  <>  " & intQuan & "  ea @  " & sngCost & "=  " & TextBox11.Text<br />
<br />
            Select Case i<br />
                Case 1<br />
                    TextBlock50.Text = txtBlock<br />
                Case 2<br />
                    TextBlock51.Text = txtBlock<br />
                Case 3<br />
                    TextBlock52.Text = txtBlock<br />
                Case 4<br />
                    TextBlock53.Text = txtBlock<br />
                Case 5<br />
                    TextBlock54.Text = txtBlock<br />
                Case 6<br />
                    TextBlock55.Text = txtBlock<br />
                Case 7<br />
                    TextBlock56.Text = txtBlock<br />
            End Select<br />
        Next<br />
<br />
        TextBox10.Text = Format(TotalCost2, "$###0.00")<br />
        txtBlock50 = "Total cost of all items for our customer, " & cusName & "=  " & TextBox10.Text<br />
<br />
        If lops = 1 Then<br />
            TextBlock51.Text = txtBlock50<br />
        End If<br />
<br />
        If lops = 2 Then<br />
            TextBlock52.Text = txtBlock50<br />
        End If<br />
<br />
        If lops = 3 Then<br />
            TextBlock53.Text = txtBlock50<br />
        End If<br />
<br />
        If lops = 4 Then<br />
            TextBlock54.Text = txtBlock50<br />
        End If<br />
<br />
        If lops = 5 Then<br />
            TextBlock55.Text = txtBlock50<br />
        End If<br />
<br />
        If lops = 6 Then<br />
            TextBlock56.Text = txtBlock50<br />
        End If<br />
<br />
        If lops > 7 Then<br />
            TextBlock57.Text = txtBlock50<br />
        End If<br />
<br />
        ''Place the TextBlocks in spInvoice<br />
        Dim container As IAddChild = spInvoice<br />
        container.AddChild(TextBlock48)<br />
        container.AddChild(TextBlock49)<br />
        container.AddChild(TextBlock50)<br />
        container.AddChild(TextBlock51)<br />
        container.AddChild(TextBlock52)<br />
        container.AddChild(TextBlock53)<br />
        container.AddChild(TextBlock54)<br />
        container.AddChild(TextBlock55)<br />
        container.AddChild(TextBlock56)<br />
        container.AddChild(TextBlock57)<br />
    End Sub</pre><br />


Bob


Bob

推荐答案

### 0.00)< br/> TotalCost2 + = TotalCost< br/> txtBlock = strNam& <>"&完整域名"ea @"&成本和费用"="& TextBox11.Text< br/> < br/> 选择案例i< br/> 案例1< br/> TextBlock50.Text = txtBlock< br/> 案例2< br/> TextBlock51.Text = txtBlock< br/> 情况3< br/> TextBlock52.Text = txtBlock< br/> 案例4< br/> TextBlock53.Text = txtBlock< br/> 案例5< br/> TextBlock54.Text = txtBlock< br/> 案例6< br/> TextBlock55.Text = txtBlock< br/> 案例7< br/> TextBlock56.Text = txtBlock< br/> 结束选择< br/> 下一个< br/> < br/> TextBox10.Text = Format(TotalCost2,"
###0.00")<br /> TotalCost2 += TotalCost<br /> txtBlock = strNam & " <> " & intQuan & " ea @ " & sngCost & "= " & TextBox11.Text<br /> <br /> Select Case i<br /> Case 1<br /> TextBlock50.Text = txtBlock<br /> Case 2<br /> TextBlock51.Text = txtBlock<br /> Case 3<br /> TextBlock52.Text = txtBlock<br /> Case 4<br /> TextBlock53.Text = txtBlock<br /> Case 5<br /> TextBlock54.Text = txtBlock<br /> Case 6<br /> TextBlock55.Text = txtBlock<br /> Case 7<br /> TextBlock56.Text = txtBlock<br /> End Select<br /> Next<br /> <br /> TextBox10.Text = Format(TotalCost2, "


### 0.00")< br/> txtBlock50 =对我们客户而言,所有项目的总费用,"& cusName& "="& TextBox10.Text< br/> < br/> 如果lops = 1那么< br/> TextBlock51.Text = txtBlock50< br/> 结束If< br/> < br/> 如果lops = 2那么< br/> TextBlock52.Text = txtBlock50< br/> 结束If< br/> < br/> 如果lops = 3则< br/> TextBlock53.Text = txtBlock50< br/> 结束If< br/> < br/> 如果lops = 4,则< br/> TextBlock54.Text = txtBlock50< br/> 结束If< br/> < br/> 如果lops = 5那么< br/> TextBlock55.Text = txtBlock50< br/> 结束If< br/> < br/> 如果lops = 6,则< br/> TextBlock56.Text = txtBlock50< br/> 结束If< br/> < br/> 如果下垂> 7然后< br/> TextBlock57.Text = txtBlock50< br/> 结束If< br/> < br/> ''将TextBlocks放入spInvoice< br/> 昏暗的容器为IAddChild = spInvoice< br/> container.AddChild(TextBlock48)< br/> container.AddChild(TextBlock49)< br/> container.AddChild(TextBlock50)< br/> container.AddChild(TextBlock51)< br/> container.AddChild(TextBlock52)< br/> container.AddChild(TextBlock53)< br/> container.AddChild(TextBlock54)< br/> container.AddChild(TextBlock55)< br/> container.AddChild(TextBlock56)< br/> container.AddChild(TextBlock57)< br/> 结束Sub</pre>< br/>
###0.00")<br /> txtBlock50 = "Total cost of all items for our customer, " & cusName & "= " & TextBox10.Text<br /> <br /> If lops = 1 Then<br /> TextBlock51.Text = txtBlock50<br /> End If<br /> <br /> If lops = 2 Then<br /> TextBlock52.Text = txtBlock50<br /> End If<br /> <br /> If lops = 3 Then<br /> TextBlock53.Text = txtBlock50<br /> End If<br /> <br /> If lops = 4 Then<br /> TextBlock54.Text = txtBlock50<br /> End If<br /> <br /> If lops = 5 Then<br /> TextBlock55.Text = txtBlock50<br /> End If<br /> <br /> If lops = 6 Then<br /> TextBlock56.Text = txtBlock50<br /> End If<br /> <br /> If lops > 7 Then<br /> TextBlock57.Text = txtBlock50<br /> End If<br /> <br /> ''Place the TextBlocks in spInvoice<br /> Dim container As IAddChild = spInvoice<br /> container.AddChild(TextBlock48)<br /> container.AddChild(TextBlock49)<br /> container.AddChild(TextBlock50)<br /> container.AddChild(TextBlock51)<br /> container.AddChild(TextBlock52)<br /> container.AddChild(TextBlock53)<br /> container.AddChild(TextBlock54)<br /> container.AddChild(TextBlock55)<br /> container.AddChild(TextBlock56)<br /> container.AddChild(TextBlock57)<br /> End Sub</pre><br />


Bob


Bob


您是否看到过此MSDN演练 [ ^ ]?

它涵盖了CRUD的基础知识.
Have you seen this walkthrough on MSDN[^]?

It covers the basics of CRUD.


这篇关于在Visual Basic中寻找WPF数据网格信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆