Showing posts with label Winforms. Show all posts
Showing posts with label Winforms. Show all posts

Friday, February 6, 2015

RadRibbonBar Application Menu | Telerik Winforms 2010 SP1 - RibbonBar - Hide the Application Menu Button

RadRibbonBar Default View

Telerik Winforms provides a RibbonBar control you can build user interfaces similar to those used in Microsoft Office 2007. The control has an Application Menu Button which is located on the upper left corner as shown below:


Sometimes you may want to hide the Application Menu Button. If you change its size to 0, you will get an error. While if you change its size to 1 (the minimal possible value), you will get something like:

Remove Application Menu Button From RadRibbonBar

To completely hide the button, try this:

this.RibbonBarElement.ApplicationButtonElement.Visibility = ElementVisibility.Collapsed;


Create a Successful Online Store at Bigcommerce! Try it Free Now!

Friday, January 30, 2015

Telerik Winforms 2010 SP1 - RadGridView - Populate ComboBoxColumn Data Source at Runtime

Assume you have a grid view radGridView1 and you have a combobox column in it. The column's header text is "Status".
You could use the following code to populate its data source at runtime.
void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
{
  if (e.Column.HeaderText == "Status")
  {
    RadComboBoxEditor editor = this.radGridView1.ActiveEditor as RadComboBoxEditor;
    RadComboBoxEditorElement element = editor.EditorElement as RadComboBoxEditorElement;

    element.DataSource = new string[] { "UP", "DOWN" };    

    element.SelectedValue = null;
    element.SelectedValue = this.radGridView1.CurrentCell.Value;
  }
}


Create a Successful Online Store at Bigcommerce! Try it Free Now!

Thursday, January 29, 2015

Winforms - Update Control from Another Thread

Assume you're using a grid view to display status for some network devices, and you have a background thread which receives status update and then update the grid view.

You could do the update safely with the following:
public delegate void UpdateStatusDelegate(StatusData data);

public void UpdateStatus(StatusData data)
{
  if (!this.radGridView1.InvokeRequired)
  {
    UpdateStatus0(data);
  }
  else
  {
    UpdateStatusDelegate del = new UpdateStatusDelegate(UpdateStatusRowStatus);
    this.radGridView1.Invoke(del, new object[] { data });
  }
}

private void UpdateStatus0(StatusData data)
{//do actual update thing
} 

Here 'radGridView1' is the grid view control (which is a control in Telerik's Winform library).

You should NOT simply call UpdateStatus0(). Doing that will give you exception at runtime.



Create a Successful Online Store at Bigcommerce! Try it Free Now!