Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Oliver Cortazar
  Where is Oliver Cortazar?
 San Luis Potosi
 Mexico
 Oliver Cortazar
 To: Cetin Basoz
  Where is Cetin Basoz?
 Izmir
 Turkey
 Cetin Basoz
 Tags
Subject: RE: VFPToolkitNET browse form
Thread ID: 228707 Message ID: 228837 # Views: 1 # Ratings: 0
Version: Not Applicable Category: .NET
Date: Friday, May 22, 2009 12:58:26 AM         
   


> >
> >
> > Thanks for all the resources. I really liked the xceed datagrid. I'll give it a try. I just wanted the browse window because is one of the VFP features I use the most, but I think I'll just programm it myself.
>
> Oh you meant how to mimic a browse? It is very simple then:
>
> myDataGridView.DataSource = yoursource
>
> myDataGridView is a DataGridView object. yoursource is anything that can be enumerated (not only a table/cursor in VFP) and has properties (properties are columns). Here is a sample code:
>
>
> using System;
> using System.Data;
> using System.Data.OleDb;
> using System.Windows.Forms;
> using System.Collections;
> using System.Linq;
> using System.IO;
> 
> class sample
> {
>  static void Main()
>  {
>    DataTable tbl = new DataTable();
>    OleDbConnection cn = new OleDbConnection(
>      "Provider=VFPOLEDB;Data Source="+
>   @"C:\Program Files\Microsoft Visual FoxPro 9\Samples\Data\testdata.dbc");
>    cn.Open();
>    OleDbDataReader rdr = new OleDbCommand("select * from customer", cn).ExecuteReader();
>    tbl.Load(rdr);
>    cn.Close();
>    
>    // table
>    Form f = new ShowDataForm(tbl);
>    f.ShowDialog();
> 
>    System.Diagnostics.Process[] runningProcesses = 
>          System.Diagnostics.Process.GetProcesses();
> 
>    // running system processes
>    f = new ShowDataForm(runningProcesses);
>    f.ShowDialog();
> 
>    // files
>    DirectoryInfo di = new DirectoryInfo(@"c:\Program Files\Microsoft Visual FoxPro 9");
>    string[] extensions = { ".scx", ".prg" };
> 
>    var files = from myFile in di.GetFiles("g*.*",SearchOption.AllDirectories)
>                where extensions.Contains(myFile.Extension.ToLower())
>                select myFile;
> 
>    f = new ShowDataForm( files.ToArray() );
>    f.ShowDialog();
> 
>  }
> }
> 
> public class ShowDataForm : Form
> {
>   public ShowDataForm(object o)  
>   {
>      this.ClientSize = new System.Drawing.Size(1024, 768);
>      this.dgv = new System.Windows.Forms.DataGridView();
>      this.dgv.DataSource = o;
>      this.dgv.Dock = DockStyle.Fill;
>      this.Controls.Add(this.dgv);
>   }
>   private DataGridView dgv;
> }
> 

>
> -Go to command window (assuming you located csc.exe - default location is something like:
> C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe)
>
> -Paste the code in notepad and saveas myTest.cs
> -Compile with
> csc myTest.cs
>
> -Run
> myTest
>
> Or alteranatively download the cool LinqPAD from www.linqpad.net and use it for testing (but it may be a little hard to see how LinqPad may help you at first - it is like an interactive IDE)
> You can also check my blog (follow signature) but I am afraid I didn't have time to update recently.
>
> Cetin Basoz
>
> .Net has got better.Think about moving - check my blog:
> Blog (main)
> Blog (mirror)

You are right, it is very simple. I'll just have to sink my nose in the books and tutorials to learn more.

I don't mean to be a bother, but could you add the code in the class ShowDataForm to release the form when you press either ESC or RETURN? It would save me a lot of research time.

I'll be also picking your brain reading your blog. I liked it very much. The first entry erased my doubth about .NET.

Thank you very much.

ENTIRE THREAD

VFPToolkitNET browse form Posted by Oliver Cortazar @ 5/21/2009 12:36:05 AM
RE: VFPToolkitNET browse form Posted by Cetin Basoz @ 5/21/2009 1:45:36 PM
RE: VFPToolkitNET browse form Posted by Oliver Cortazar @ 5/21/2009 8:09:47 PM
RE: VFPToolkitNET browse form Posted by Cetin Basoz @ 5/21/2009 10:59:56 PM
RE: VFPToolkitNET browse form Posted by Oliver Cortazar @ 5/22/2009 12:58:26 AM
RE: VFPToolkitNET browse form Posted by Cetin Basoz @ 5/22/2009 2:32:45 PM
RE: VFPToolkitNET browse form Posted by Oliver Cortazar @ 5/22/2009 6:56:08 PM
RE: VFPToolkitNET browse form Posted by Oliver Cortazar @ 5/22/2009 9:33:50 PM
RE: VFPToolkitNET browse form Posted by Cetin Basoz @ 5/23/2009 12:29:46 PM
RE: VFPToolkitNET browse form Posted by Christian Tabligan @ 5/21/2009 1:58:58 PM
RE: VFPToolkitNET browse form Posted by Oliver Cortazar @ 5/21/2009 8:13:55 PM
RE: VFPToolkitNET browse form Posted by Tom Saddul @ 5/23/2009 5:23:39 AM
RE: VFPToolkitNET browse form Posted by Boudewijn Lutgerink @ 5/25/2009 8:46:22 AM