Substringにて、任意の位置から指定した文字数分の文字列を取出す。

1. 名前空間

using System;
using System.Windows.Forms;

2. コード

  string s1 = "Hello, World!";

  // 左端から 5 文字取り出す。
  this.TextBox1.Text = s1.Substring(0, 5);

  // 左 5 文字目から 2 文字取り出す。

  this.TextBox1.Text = s1.Substring(5, 2);

// 右端から 6 文字取り出す。

  this.TextBox1.Text = s1.Substring(s1.Length-6, 6);

■ 説明
Substringにて、任意の位置から指定した文字数分の文字列を取出す。

Substring は開始方向から文字列を取出します。

今日の御ことば

BIBLE(新改訳聖書、KJV)

詩篇
25:5 あなたの真理のうちに私を導き、私を教えてください。あなたこそ、私の救いの神、私は、あなたを一日中待ち望んでいるのです。

【KJV】 25:5 Lead me in thy truth, and teach me: for thou art the God of my salvation; on thee do I wait all the day.

MultiRow for Windows Forms 6.0Jで、コンボボックスに動的にデータセット

MultiRow for Windows Forms 6.0Jで、コンボボックスに動的にデータセット

既存のテンプレートのコンボボックス型セルに対して、リストを設定

するには下記のサンプルコードのようにします。

この例では、Template1がデザイナで作成したテンプレートになります。

【サンプルコード】

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using GrapeCity.Win.MultiRow;

namespace M100902020

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

InitializeMultiRow();

}

private void InitializeMultiRow()

{

// 既存のテンプレートの変更

Template test = new Template1();

ComboBoxCell comboCell = test.Row.Cells[“comboBoxCell1”] as ComboBoxCell;

comboCell.Items.Add(“ガーナ”);

comboCell.Items.Add(“バングラデッシュ”);

comboCell.Items.Add(“ネパール”);

// MultiRowの設定

gcMultiRow1.Template = test;

gcMultiRow1.SetValue(0, “comboBoxCell1”, “ネパール”);

}

}

}

TableAdapterに ‘Update’ の定義が含まれておらず

ウィザードで、DataSetを構成
ウィザードで、DataSetを構成

【エラー1】
・・・TableAdapters.TableAdapter’ に ‘Update’ の定義が含まれておらず、型 ‘・・・TableAdapter’ の最初の引数を受け付ける拡張メソッドが見つかりませんでした。
using ディレクティブまたはアセンブリ参照が不足しています。

【対処】

ウィザードで続行する
ウィザードで続行する
データセット内に指定するデータベース オブジェクト
データセット内に指定するデータベース オブジェクト

C# 文字列を数値変換

//文字列をint型に変換
int i = int.Parse(“100”);

//文字列をlong型に変換
long l = long.Parse(“100”);

//文字列をfloat型に変換
float f = float.Parse(“100.1”);

//文字列をdouble型に変換
double d = double.Parse(“100.1”);

//文字列をbool型に変換
bool b = bool.Parse(“True”);

ClickOnceが持つセキュリティ

[エラーメッセージ]
警告 1 Importing key file “□□□_TemporaryKey.pfx” was canceled.

ONECECLICK署名

[解決策]
「コードサイニング証明書(Authenticode対応Digital ID)」が必要となる。
ClickOnceの証明書を作成する
VS2008にて、ソリューションエクスプローラ
「Properties」 → 「署名」 → 「ファイルから選択」 or 「テスト署名作成」
証明書(C)に、発行先/発行元/使用目的/有効期限が表示されます。
→ ビルド