Box のデータをDevExpress Data Grid にデータバインドする。

加藤龍彦
加藤龍彦
デジタルマーケティング
Box 用の CData ADO.NET プロバイダーをDevExpress Windows Forms とWeb コントロールとともに使用し、Box をチャートに入力します。

Box 用の CData ADO.NET プロバイダーはサードパーティーコントロールで使うことのできる通常のADO.NET データベースアクセスコンポーネントを実装しています。データバインドするための通常のADO.NET プロセスに従うことで、UI コントロールから実データへの双方向アクセスを可能にします。 この記事では、CData を使ってDevExpress Windows Forms とウェブコントロールにデータバインドする方法を説明します。ここでは、最新のデータを表示するチャートにデータバインドします。

Box 接続プロパティの取得・設定方法

Box は、認証にOAuth スタンダードを使用します。Box への認証には、登録アプリのOAuthClientId、OAuthClientSecret、CallbackURL を取得して、接続プロパティに設定してください。詳細はヘルプドキュメントの「はじめに」を参照してください。

なお、Box Driver はBox のファイルの一覧表示やユーザー管理情報の取得用です。Box に保管されているExcel、CSV、JSON などのファイル内のデータを読み込みたい場合には、それぞれExcel DriverCSV DriverJSON Driver をご利用ください。

Windows Forms コントロール

下のコードでは、Box でDevExpress のチャートに追加する方法を説明します。BoxDataAdapter はチャートコントロールのSeries プロパティにバインドします。コントロールのDiagram プロパティはx 軸とy 軸をカラム名として定義します。

using (BoxConnection connection = new BoxConnection(
"OAuthClientId=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;CallbackURL=http://localhost:33333;")) {
  BoxDataAdapter dataAdapter = new BoxDataAdapter(
  "SELECT Name, Size FROM Files", connection);

  DataTable table = new DataTable();
  dataAdapter.Fill(table);
  DevExpress.XtraCharts.Series series = new DevExpress.XtraCharts.Series();
  chartControl1.Series.Add(series);
  DataTable table = new DataTable();
  series.ValueDataMembers.AddRange(new string[] { "Size" });
  series.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Qualitative;
  series.ArgumentDataMember = "Name";
  series.ValueScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
  chartControl1.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
  ((DevExpress.XtraCharts.SideBySideBarSeriesView)series.View).ColorEach = true;
}
The complete code example and the resulting chart.

Web コントロール

下のコードではBox でDevExpress Web を操作するための設定方法を説明します。BoxDataAdapter はチャートのSeries プロパティにバインドします。Diagram プロパティはx 軸とy 軸をカラム名として定義します。

using DevExpress.XtraCharts;

using (BoxConnection connection = new BoxConnection(
"OAuthClientId=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;CallbackURL=http://localhost:33333;"))
{
  BoxDataAdapter BoxDataAdapter1 = new BoxDataAdapter("SELECT Name, Size FROM Files", connection);
  DataTable table = new DataTable();
  BoxDataAdapter1.Fill(table);
  DevExpress.XtraCharts.Series series = new Series("Series1", ViewType.Bar);
  WebChartControl1.Series.Add(series);
  DataTable table = new DataTable();
  series.ValueDataMembers.AddRange(new string[] { "Size" });
  series.ArgumentScaleType = ScaleType.Qualitative;
  series.ArgumentDataMember = "Name";
  series.ValueScaleType = ScaleType.Numerical;
  ((DevExpress.XtraCharts.SideBySideBarSeriesView)series.View).ColorEach = true;
}
An ASP.NET application created with the ADO.NET Provider and the DevExpress Web Forms control.(Salesforce is shown.)

はじめる準備はできましたか?

Box Data Provider の無料トライアルをダウンロードしてお試しください:

 ダウンロード

詳細:

Box Icon Box ADO.NET Provider お問い合わせ

Box ファイルストレージデータと連携する.NET アプリケーションを素早く作成して配布。