作成日: 2018/10/31 最終更新日: 2018/10/31
文書種別
使用方法
詳細
FlexViewer for WinForms のリボンは、Ribbon for WinForms を使用して構築されています。
このリボンにボタンを追加したい場合は、C1.Win.C1Ribbon.RibbonButtonオブジェクトを生成して追加してください。
一例として、「ビュー」グループにボタンを追加する処理を以下に記載します。
◆サンプルコード(VB.NET)
◆サンプルコード(C#)
独自のグループにボタンを配置する場合は、以下のような処理になります。
◆サンプルコード(VB.NET)
◆サンプルコード(C#)
このリボンにボタンを追加したい場合は、C1.Win.C1Ribbon.RibbonButtonオブジェクトを生成して追加してください。
一例として、「ビュー」グループにボタンを追加する処理を以下に記載します。
◆サンプルコード(VB.NET)
Imports C1.Win.Ribbon
...
Private customButton As New RibbonButton()
Private Sub customButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
' 独自の処理
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' ボタン下部に表示する文字列
customButton.Text = "カスタム"
' ボタンに表示する画像(32×32)
customButton.LargeImage = My.Resources.img32
' イベントハンドラ
AddHandler customButton.Click, AddressOf customButton_Click
' 「ビュー」グループにボタン追加
C1FlexViewer1.RibbonGroups.View.RibbonGroup.Items.Add(customButton)
End Sub
...
Private customButton As New RibbonButton()
Private Sub customButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
' 独自の処理
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' ボタン下部に表示する文字列
customButton.Text = "カスタム"
' ボタンに表示する画像(32×32)
customButton.LargeImage = My.Resources.img32
' イベントハンドラ
AddHandler customButton.Click, AddressOf customButton_Click
' 「ビュー」グループにボタン追加
C1FlexViewer1.RibbonGroups.View.RibbonGroup.Items.Add(customButton)
End Sub
◆サンプルコード(C#)
using C1.Win.Ribbon;
...
private RibbonButton customButton = new RibbonButton();
private void customButton_Click(System.Object sender, System.EventArgs e)
{
// 独自の処理
}
private void Form1_Load(object sender, EventArgs e)
{
// ボタン下部に表示する文字列
customButton.Text = "カスタム";
// ボタンに表示する画像(32×32)
customButton.LargeImage = Properties.Resources.img32;
// イベントハンドラ
customButton.Click += customButton_Click;
// 「ビュー」グループにボタン追加
c1FlexViewer1.RibbonGroups.View.RibbonGroup.Items.Add(customButton);
}
...
private RibbonButton customButton = new RibbonButton();
private void customButton_Click(System.Object sender, System.EventArgs e)
{
// 独自の処理
}
private void Form1_Load(object sender, EventArgs e)
{
// ボタン下部に表示する文字列
customButton.Text = "カスタム";
// ボタンに表示する画像(32×32)
customButton.LargeImage = Properties.Resources.img32;
// イベントハンドラ
customButton.Click += customButton_Click;
// 「ビュー」グループにボタン追加
c1FlexViewer1.RibbonGroups.View.RibbonGroup.Items.Add(customButton);
}
独自のグループにボタンを配置する場合は、以下のような処理になります。
◆サンプルコード(VB.NET)
Dim customGroup As New RibbonGroup()
customGroup.Text = "カスタム"
' グループ縮小時に表示される画像(16×16)
customGroup.Image = My.Resources.img16
customGroup.Items.Add(customButton)
C1FlexViewer1.Ribbon.Tabs(0).Groups.Add(customGroup)
customGroup.Text = "カスタム"
' グループ縮小時に表示される画像(16×16)
customGroup.Image = My.Resources.img16
customGroup.Items.Add(customButton)
C1FlexViewer1.Ribbon.Tabs(0).Groups.Add(customGroup)
◆サンプルコード(C#)
RibbonGroup customGroup = new RibbonGroup();
customGroup.Text = "カスタム";
// グループ縮小時に表示される画像(16×16)
customGroup.Image = Properties.Resources.img16;
customGroup.Items.Add(customButton);
c1FlexViewer1.Ribbon.Tabs[0].Groups.Add(customGroup);
customGroup.Text = "カスタム";
// グループ縮小時に表示される画像(16×16)
customGroup.Image = Properties.Resources.img16;
customGroup.Items.Add(customButton);
c1FlexViewer1.Ribbon.Tabs[0].Groups.Add(customGroup);
関連情報
旧文書番号
83358