246 lines
12 KiB
HTML
246 lines
12 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<head>
|
|
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
|
<title>Better SplitButton Properties</title>
|
|
<link href="style.css" rel="stylesheet" type="text/css">
|
|
<link href="prettify.css" type="text/css" rel="stylesheet">
|
|
<script type="text/javascript" src="prettify.js"></script><script type="text/javascript" src="lang-vb.js"></script><link href="../resources/main.css" media="screen" rel="stylesheet" type="text/css">
|
|
</head>
|
|
<body onload="prettyPrint()"><div class="placing">
|
|
<br><table class="navigation"><tr>
|
|
<td class="navigation-previous"><a href="../../../better-splitbutton/quick-start-guide.html"><strong>
|
|
« Quick Start</strong></a></td>
|
|
<td class="navigation-index"><a href="../../../better-splitbutton/documentation.html"><strong>Index</strong></a></td>
|
|
<td class="navigation-next"><a href="chapter-known-issues.html"><strong>Known Issues »
|
|
</strong></a></td>
|
|
</tr></table>
|
|
<br><h1>Better SplitButton Properties</h1>
|
|
<div class="banner">
|
|
<a href="../../../blog/page/6/index.html"><img src="../resources/overview.gif" alt="Better ListView" class="ss"></a>
|
|
<div class="inside">
|
|
<div class="text">Better ListView: Ultimate .NET ListView replacement control for WinForms (C#, VB.NET)</div>
|
|
<span class="dbtn-c dbtn-hilight"><span class="dbtn-w"><a href="../../../betterlistview.exe" class="dbtn">Download</a></span></span>
|
|
<span class="dbtn-c"><span class="dbtn-w"><a href="../../../blog/page/6/index.html" class="dbtn">More Info</a></span></span>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<h2>SplitSize property</h2>
|
|
|
|
|
|
<p>This property indicates the <strong><em>width</em></strong> of the split
|
|
part in <strong><em>pixels</em></strong>. The button changes appearance as you
|
|
change the value. If you set the value to <span class="code">0</span> the control will
|
|
look and behave same as the classic <span class="code">Button</span> class. If you set
|
|
the value to be as high as the width of the whole control then only the
|
|
split part will be drawn. You can see how this property affects the
|
|
control in <span class="code">BetterSplitButtonSamplesCS</span> sample project:</p>
|
|
|
|
<p class="images"><img src="size_glyph.png"></p>
|
|
|
|
|
|
<h2>SplitImageList property</h2>
|
|
|
|
|
|
<p>This property allows you to display <strong><em>images in the split
|
|
part</em></strong>. You can display different image for each button state. It
|
|
expects - if not <span class="code">null</span> - a instance of the
|
|
<span class="code">ImageList</span> class with six images in it. Each index in the list
|
|
coresponds to a state of the button so you can animate the images
|
|
according to your prefference. The states and their coresponding indexes
|
|
are as follows:</p>
|
|
<p><strong>C#</strong></p>
|
|
<pre class="prettyprint"><code class="lang-cs">Normal = 0 // mouse is not in the control
|
|
ButtonHot = 1 // mouse is in the button area
|
|
ButtonPressed = 2 // mouse down in the button area
|
|
SplitHot = 3 // mouse is in the split area
|
|
SplitPressed = 4 // mouse down in the split area
|
|
Disabled = 5 // the control is disabled</code></pre>
|
|
<br><hr>
|
|
<p class="note">If the control won't find an image in the coresponding index of
|
|
the <span class="code">SplitImageList</span> it will display Normal (index
|
|
<span class="code">0</span>) image.</p>
|
|
<hr>
|
|
<br><p>You can find an example in the
|
|
<span class="code">BetterSplitButtonSamplesCS.cs</span> code file:</p>
|
|
|
|
<p><strong>C#</strong></p>
|
|
<pre class="prettyprint"><code class="lang-cs">// create the image list for the button states
|
|
ImageList splitImageList = new ImageList();
|
|
splitImageList.ImageSize = new Size(48, 48);
|
|
splitImageList.ColorDepth = ColorDepth.Depth32Bit;
|
|
|
|
// load the images for all the button states
|
|
// THE INDEX IN THE LIST CORESPONDS TO THE STATE OF THE BUTTON
|
|
splitImageList.Images.Add(Image.FromStream(thisAssembly.GetManifestResourceStream("ComponentOwl.BetterSplitButtonSamplesCS.Resources.state_normal.png")));
|
|
splitImageList.Images.Add(Image.FromStream(thisAssembly.GetManifestResourceStream("ComponentOwl.BetterSplitButtonSamplesCS.Resources.state_button_hot.png")));
|
|
splitImageList.Images.Add(Image.FromStream(thisAssembly.GetManifestResourceStream("ComponentOwl.BetterSplitButtonSamplesCS.Resources.state_button_pressed.png")));
|
|
splitImageList.Images.Add(Image.FromStream(thisAssembly.GetManifestResourceStream("ComponentOwl.BetterSplitButtonSamplesCS.Resources.state_split_hot.png")));
|
|
splitImageList.Images.Add(Image.FromStream(thisAssembly.GetManifestResourceStream("ComponentOwl.BetterSplitButtonSamplesCS.Resources.state_split_pressed.png")));
|
|
splitImageList.Images.Add(Image.FromStream(thisAssembly.GetManifestResourceStream("ComponentOwl.BetterSplitButtonSamplesCS.Resources.state_disabled.png")));
|
|
|
|
// assign the list to the button
|
|
this.bsbSplitImage.SplitImageList = splitImageList;</code></pre>
|
|
|
|
<p><strong>Visual Basic</strong></p>
|
|
<pre class="prettyprint"><code class="lang-vb">' create the image list for the button states
|
|
Dim splitImageList As New ImageList()
|
|
splitImageList.ImageSize = New Size(48, 48)
|
|
splitImageList.ColorDepth = ColorDepth.Depth32Bit
|
|
|
|
' load the images for all the button states
|
|
' THE INDEX IN THE LIST CORESPONDS TO THE STATE OF THE BUTTON
|
|
splitImageList.Images.Add(Image.FromStream(thisAssembly.GetManifestResourceStream("ComponentOwl.BetterSplitButtonSamplesCS.Resources.state_normal.png")))
|
|
splitImageList.Images.Add(Image.FromStream(thisAssembly.GetManifestResourceStream("ComponentOwl.BetterSplitButtonSamplesCS.Resources.state_button_hot.png")))
|
|
splitImageList.Images.Add(Image.FromStream(thisAssembly.GetManifestResourceStream("ComponentOwl.BetterSplitButtonSamplesCS.Resources.state_button_pressed.png")))
|
|
splitImageList.Images.Add(Image.FromStream(thisAssembly.GetManifestResourceStream("ComponentOwl.BetterSplitButtonSamplesCS.Resources.state_split_hot.png")))
|
|
splitImageList.Images.Add(Image.FromStream(thisAssembly.GetManifestResourceStream("ComponentOwl.BetterSplitButtonSamplesCS.Resources.state_split_pressed.png")))
|
|
splitImageList.Images.Add(Image.FromStream(thisAssembly.GetManifestResourceStream("ComponentOwl.BetterSplitButtonSamplesCS.Resources.state_disabled.png")))
|
|
|
|
' assign the list to the button
|
|
Me.bsbSplitImage.SplitImageList = splitImageList
|
|
</code></pre>
|
|
|
|
<br><hr>
|
|
<p class="note">Make sure that the dimensions of the controls and the
|
|
<span class="code">SplitSize</span> property are set such that the images in
|
|
<span class="code">SplitImageList</span> can fit in the resulting split area. The
|
|
images <strong><em>won't</em></strong> scale down or up to fit.</p>
|
|
<hr>
|
|
<br><p>To illustrate here is an example of how different images can be
|
|
displayed in each button state:</p>
|
|
|
|
<p class="images"><img src="split_images.png"></p>
|
|
|
|
|
|
<h2>SplitGlyphScaling property</h2>
|
|
|
|
|
|
<p>If <span class="code">SplitImageList</span> property is <span class="code">null</span> or
|
|
empty the <strong><em>default glyph</em></strong> is drawn in the split area.
|
|
By setting this property you can control size of that glyph. If set to
|
|
<span class="code">0</span>, no glyph will be drawn. You can see how this property
|
|
affects the control in <span class="code">BetterSplitButtonSamplesCS</span> sample
|
|
project.</p>
|
|
|
|
|
|
<h2>AlwaysDropDown property</h2>
|
|
|
|
|
|
<p>This property allows you to instruct the control to display context
|
|
menu after mouse click <strong><em>regardless of the mouse
|
|
position</em></strong>. In other words, if set true the button will always
|
|
display context menu after mouse click. Also, it won't display the line
|
|
between the button area and the split area. You can see how this property
|
|
affects the control in <span class="code">BetterSplitButtonSamplesCS</span> sample
|
|
project.</p>
|
|
|
|
|
|
<h2>BlockEnterAndSpaceBar property</h2>
|
|
|
|
|
|
<p>If set true, you wont be able to perform a mouse click by hitting
|
|
Enter or Space key. You can see how this property affects the control in
|
|
<span class="code">BetterSplitButtonSamplesCS</span> sample project.</p>
|
|
|
|
|
|
<h2>DoubleClickEnabled property</h2>
|
|
|
|
|
|
<p>If set true, a <span class="code">SplitButtonDoubleClick</span>
|
|
<strong><em>event</em></strong> will occur if you double-click in the split
|
|
area.</p>
|
|
|
|
|
|
<h2>Setting Up The Context Menu</h2>
|
|
|
|
|
|
<p>To display the context menu you have to assign an instance of
|
|
<span class="code">ContextMenuStrip</span> class to the <span class="code">ContextMenuStrip</span>
|
|
<strong><em>property</em></strong>. If this property is <span class="code">null</span> or
|
|
the menu is empty it won't display anything. To set up your
|
|
<span class="code">ContextMenuStrip</span> intance you can you the Visual Studio
|
|
designer which makes the process very easy. However if yous wish to
|
|
construct your menu in code by yourself there's no harm in doing that. We
|
|
even provide you with special <span class="code">BeforeMenuShown</span>
|
|
<strong><em>event</em></strong> where you can construct your context menu
|
|
dynamically. Good example of this technique can be found in
|
|
<span class="code">BetterSplitButtonSamplesCS.cs</span> code file:</p>
|
|
<p><strong>C#</strong></p>
|
|
<pre class="prettyprint"><code class="lang-cs">private void bsbBrowse_BeforeMenuShown(object sender, EventArgs e)
|
|
{
|
|
// clear any previous items
|
|
this.cmsBrowse.Items.Clear();
|
|
|
|
// get all files in current directory
|
|
string[] filesInCurDir = Directory.GetFiles(Environment.CurrentDirectory);
|
|
|
|
foreach (string fileName in filesInCurDir)
|
|
{
|
|
// get some info
|
|
FileInfo fi = new FileInfo(fileName);
|
|
|
|
// add menu item for each file
|
|
ToolStripMenuItem tsmiNewImageFile = new ToolStripMenuItem(" " + fi.Name);
|
|
tsmiNewImageFile.Click += new EventHandler(tsmiNewImageFile_Click);
|
|
cmsBrowse.Items.Add(tsmiNewImageFile);
|
|
}
|
|
|
|
// add label and separator to Browse context menu
|
|
ToolStripLabel tslCurDir = new ToolStripLabel("Current Directory:");
|
|
cmsBrowse.Items.Insert(0, tslCurDir);
|
|
cmsBrowse.Items.Insert(1, new ToolStripSeparator());
|
|
}</code></pre>
|
|
<p><strong>Visual Basic</strong></p>
|
|
<pre class="prettyprint"><code class="lang-vb">Private Sub bsbBrowse_BeforeMenuShown(sender As Object, e As EventArgs)
|
|
' clear any previous items
|
|
Me.cmsBrowse.Items.Clear()
|
|
|
|
' get all files in current directory
|
|
Dim filesInCurDir As String() = Directory.GetFiles(Environment.CurrentDirectory)
|
|
|
|
For Each fileName As String In filesInCurDir
|
|
' get some info
|
|
Dim fi As New FileInfo(fileName)
|
|
|
|
' add menu item for each file
|
|
Dim tsmiNewImageFile As New ToolStripMenuItem(" " + fi.Name)
|
|
tsmiNewImageFile.Click += New EventHandler(tsmiNewImageFile_Click)
|
|
cmsBrowse.Items.Add(tsmiNewImageFile)
|
|
Next
|
|
|
|
' add label and separator to Browse context menu
|
|
Dim tslCurDir As New ToolStripLabel("Current Directory:")
|
|
cmsBrowse.Items.Insert(0, tslCurDir)
|
|
cmsBrowse.Items.Insert(1, New ToolStripSeparator())
|
|
End Sub</code></pre>
|
|
|
|
<br><div class="banner">
|
|
<a href="../../../blog/page/6/index.html"><img src="../resources/overview.gif" alt="Better ListView" class="ss"></a>
|
|
<div class="inside">
|
|
<div class="text">Better ListView: Ultimate .NET ListView replacement control for WinForms (C#, VB.NET)</div>
|
|
<span class="dbtn-c dbtn-hilight"><span class="dbtn-w"><a href="../../../betterlistview.exe" class="dbtn">Download</a></span></span>
|
|
<span class="dbtn-c"><span class="dbtn-w"><a href="../../../blog/page/6/index.html" class="dbtn">More Info</a></span></span>
|
|
</div>
|
|
</div>
|
|
<table class="navigation"><tr>
|
|
<td class="navigation-previous"><a href="../../../better-splitbutton/quick-start-guide.html"><strong>
|
|
« Quick Start</strong></a></td>
|
|
<td class="navigation-index"><a href="../../../better-splitbutton/documentation.html"><strong>Index</strong></a></td>
|
|
<td class="navigation-next"><a href="chapter-known-issues.html"><strong>Known Issues »
|
|
</strong></a></td>
|
|
</tr></table>
|
|
<br><table class="footer"><tr>
|
|
<td class="footer-title">Better SplitButton Documentation
|
|
</td>
|
|
<td class="footer-copyright">
|
|
Copyright © <a href="../../../index.html" target="_blank">ComponentOwl.com</a>
|
|
</td>
|
|
</tr></table>
|
|
</div></body>
|
|
</html>
|