Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / September 2005

Tip: Looking for answers? Try searching our database.

Using Msgraph directly in VB.NET application

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Doudou - 26 Aug 2005 09:10 GMT
Hello,
First I'm french, so my english isn't very good.

I try to find explanation or example to use MsGraph object directly in
VB.NET application (in a windows form for example).

Is it possible ? Or is it necessary to use Office application (like
Excel) to use MsGraph object ?

Thanks for all response
Steph
Mona - 30 Aug 2005 09:34 GMT
Hi Steph,

Regarding this issue of using the MS Chart directly in VB.Net application ,
I would like to tell you that first of all we need to add the MSChart
control in the toolbox. It will be in the Components Tab when you Add/Remove
the toolbox items.

Add an MS Chart control to a form and suppose the name of the Chart control
is Chart1, then we need to use the following snippet of code :

START CODE

Dim arrData(2, 2) As object

arrData(1, 1) = "Jan" ' Set the labels in the first series.

arrData(2, 1) = "Feb"

arrData(1, 2) = 8

arrData(2, 2) = 4

Chart1.ChartData = arrData

END CODE

Hope this helps.

Regards,
Mona [Grapecity]

> Hello,
> First I'm french, so my english isn't very good.
[quoted text clipped - 7 lines]
> Thanks for all response
> Steph
Uday Takbhate [MSFT] - 19 Sep 2005 06:58 GMT
Thanks for Brief answer Mona,

Mona had given good example to use MS Chart which is a part of Office Web
Components on the VB.NET form.
The MS Chart has basic functionality of a displaying the chart. If you are
looking at something fancy then you can use the MS Graph on a WinForm.

All you have to do is,
(1) Add the reference of Microsoft Graph from the Add reference->COM tab
(2) The script will look something like,

       Dim values(,) As Integer = {{1, 2, 3, 4}, _
                                   {4, 5, 6, 7}, _
                                   {7, 8, 9, 10}, _
                                   {10, 11, 12, 14} _
                                  }

       Dim oGraph As New Graph.Global
       Dim oDataSheet As Graph.DataSheet

       oDataSheet = oGraph.Application.DataSheet

       ' Place headers into data table.
       ' Create four column headers.
       oDataSheet.Cells(1, 2).Value = "Col1"
       oDataSheet.Cells(1, 3).Value = "Col2"
       oDataSheet.Cells(1, 4).Value = "Col3"
       oDataSheet.Cells(1, 5).Value = "Col4"
       ' Create four row headers.
       oDataSheet.Cells(2, 1).Value = "Row1"
       oDataSheet.Cells(3, 1).Value = "Row2"
       oDataSheet.Cells(4, 1).Value = "Row3"
       oDataSheet.Cells(5, 1).Value = "Row4"

       ' Get four rows of data.
       Dim lRowCnt, lColCnt As Integer
       For lRowCnt = 2 To 5
           For lColCnt = 2 To 5
               oDataSheet.Cells(lRowCnt, lColCnt).Value = values(lRowCnt -
2, lColCnt - 2)
           Next lColCnt
       Next lRowCnt

       Dim oChart As Graph.Chart
       oChart = oGraph.Application.Chart

       Dim oAxis As Graph.Axis
       oAxis = oChart.Axes(Graph.XlAxisType.xlValue,
Graph.XlAxisGroup.xlPrimary)
       oAxis.CrossesAt = 7

       oChart.Export(FileName:="current_sales.gif", FilterName:="GIF")

       oAxis = Nothing
       oChart = Nothing
       oDataSheet = Nothing

       oGraph.Application.Quit()
       oGraph = Nothing

For more information on Microsoft Graph object model, refer to,
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbagr10/htm
l/grtocobjectmodelapplication.asp

I hope this information helps!

Regards,
Uday Takbhate [MSFT]
Microsoft Developer Support
--------------------
>From: "Mona" <mona@discussions.com>
>References: <1125043844.608051.107310@o13g2000cwo.googlegroups.com>
[quoted text clipped - 54 lines]
>> Thanks for all response
>> Steph

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.