|
/*
* Copyright (c) 2004 Marc Clifton
* All Rights Reserved
*
* License: GNU General Public License, see doc\license.txt
* http://www.gnu.org/licenses/licenses.html#GPL
* Owner: Marc Clifton email: webmaster@knowledgeautomation.com
* First release published:
* http://www.codeproject.com/cs/miscctrl/xmlGuiGenerator.asp
* 2/25/04
*/
using System;
using System.Data;
using System.Windows.Forms;
namespace MyXaml.Extensions
{
public class MxRadioButton : RadioButton
{
protected int index;
public int Index
{
get
{
index=-1;
int idx=0;
foreach (Control c in Parent.Controls)
{
if (c is RadioButton)
{
if (((RadioButton)c).Checked)
{
index=idx;
break;
}
else
{
++idx;
}
}
}
return index;
}
set
{
index=value;
int idx=index;
foreach (Control c in Parent.Controls)
{
if (c is RadioButton)
{
if (idx==0)
{
((RadioButton)c).Checked=true;
}
else
{
((RadioButton)c).Checked=false;
}
--idx;
}
}
}
}
public MxRadioButton()
{
CheckedChanged+=new EventHandler(CheckedChangedEvent);
}
private void CheckedChangedEvent(object sender, EventArgs e)
{
foreach(Control c in Parent.Controls)
{
if (c is RadioButton)
{
if (c.DataBindings.Count==1)
{
Binding binding=c.DataBindings[0];
if (binding.PropertyName=="Index")
{
DataTable dt=binding.DataSource as DataTable;
if (dt != null)
{
dt.Rows[0][binding.BindingMemberInfo.BindingMember]=Index;
}
break;
}
}
}
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here