public Form1()
{
InitializeComponent();
RadSplitButtonElement btnAttachFileDocument;
btnAttachFileDocument = new RadSplitButtonElement();
btnAttachFileDocument.Text = "Attach File";
btnAttachFileDocument.Click += new EventHandler(btnAttachFileDocument_Click);
btnAttachFileDocument.DropDownOpened += new EventHandler(btnAttachFileDocument_DropDownOpened);
RadLabelElement oMenuItem;
oMenuItem = new RadLabelElement();
oMenuItem.Text = "Cover Sheet";
oMenuItem.Click += new EventHandler(oMenuItem_Click);
btnAttachFileDocument.Items.Add(oMenuItem);
oMenuItem = new RadLabelElement();
oMenuItem.Text = "Master Waybill Doc";
btnAttachFileDocument.Items.Add(oMenuItem);
radRibbonBar1.CommandTabs[0].Items.Add(btnAttachFileDocument);
}
void oMenuItem_Click(object sender, EventArgs e)
{
this.Text = "Cover Sheet Clicked";
}
void btnAttachFileDocument_DropDownOpened(object sender, EventArgs e)
{
this.Text = "DropDown";
}
void btnAttachFileDocument_Click(object sender, EventArgs e)
{
this.Text = "Clicked";
}
I have 2 issues .
Firstly I cannot get a seperate event when clicking the dropdown arrow of the button or when clicking the button itself.
I want to generate a default click event if the user clicks the button but if he opens the drop down I want to wait for him
to select the appropriate item from the list. At the moment I always get the click event when the dropdown opens. How
do I prevent this ?
Secondly , with the splitbutton control I can mouseover the dropdown arrow and button seperately and it highlights them
seperately . WIth the splitbuttonelement that I add to the ribbonbar however it always highlights it all as one control always
and I can only ever see the Image regardless of the textimage relation I setup . My text is always invisible ...
| private void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e) |
| { |
| // exclude header element in the data column |
| if (e.CellElement.ColumnInfo is GridViewDataColumn && !(e.CellElement.RowElement is GridTableHeaderRowElement)) |
| { |
| GridViewDataColumn column = (GridViewDataColumn)e.CellElement.ColumnInfo; |
| if (column.FieldName == "Discount") |
| { |
| // check if the progress bar is already added to the cell |
| if (e.CellElement.Children.Count > 0) |
| return; |
| RadProgressBarElement element = new RadProgressBarElement(); |
| e.CellElement.Children.Add(element); |
| element.StretchHorizontally = true; |
| element.StretchVertically = true; |
| // extract the value in the cell, convert it to a value |
| // usable in the progress bar element and assign it to the |
| // progress bar Value1 and Text properties |
| object discountValue = e.CellElement.RowInfo.Cells["Discount"].Value; |
| int discountPercentage = Convert.ToInt32(Convert.ToDecimal(discountValue) * 100); |
| element.Value1 = discountPercentage; |
| if (discountPercentage > 0) |
| { |
| element.Text = discountPercentage.ToString() + "%"; |
| } |
| // apply theme to the progress bar |
| ApplyThemeToElement(element, "ControlDefault"); |
| } |
| } |
| } |
| private void ApplyThemeToElement(RadItem item, string themeName) |
| { |
| DefaultStyleBuilder builder = |
| ThemeResolutionService.GetStyleSheetBuilder(item, themeName) as DefaultStyleBuilder; |
| if (builder != null) |
| //clone because control might modify it later |
| item.Style = new XmlStyleSheet(builder.Style).GetStyleSheet(); |
| } |