Hi there,
I am currently developing an MDI application exploiting your Raddock Control.
As I am using forms as tabbed windows, I would like my application not to create a new tab (a second one), if the form is already open.
Currently I am using the following workaround and nonetheless I don’t like very much this way J
private void AddTabbedForm(BaseForm form)
{
if (this.radDock1.DockWindows.DocumentWindows.Where(w => w.Text == form.Text).Count() > 0)
{
this.radDock1.ActivateWindow(this.radDock1.DockWindows.DocumentWindows.Where(w => w.Text == form.Text).First());
return;
}
form.MdiParent = this;
form.Show();
}
Any hint to have it implemented in a more elegant way?
A few threads have been posted over the years to ask about natural sorting, which is clicking a column header to go Ascending, Descending, then back to the default unsorted mode on the third click. I looked around for a tri-state or three-state toggle and didn't find any info. Very helpful but incomplete info is found here and here, so I thought I'd provide C# code to help anyone else looking to do this. Some threads refer to MasterGridViewTemplate.AllowNaturalSort but that property no longer exists. My code is adapted from the second forum posting referenced. It looks like the library has changed since Sean wrote his code.
Telerik.WinControls.Data.SortDescriptor.Direction is of type System.ComponentModel.ListDirection, and that enum only has two values. So the Boolean _sorted is used - if the grid is sorted in ascending or descending order, then use the sort order, but if we click past descending order, set _sorted to false (natural sort!) and clear the SortDescriptors.
Of course clearing SortDescriptors means this only works with single column sorting. Maybe someone will follow-up here with a solution that works with multiple columns.
HTH
using
System.ComponentModel;
bool
_sorted =
false
;
ListSortDirection _previousGridColumnSortDirection;
private
void
radGridView1_SortChanging(
object
sender, GridViewCollectionChangingEventArgs e)
{
try
{
Telerik.WinControls.Data.SortDescriptor sortField;
// Only proceed if we are changing an existing sorting (not starting a new one)
// Make sure we have an item
if
(e.NewItems !=
null
&& e.NewItems.Count > 0)
{
sortField = (Telerik.WinControls.Data.SortDescriptor)e.NewItems[0];
if
(e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.ItemChanging)
{
// If the current SortOrder is Ascending, and the previous SortOrder
// was Descending, then clear the sorting.
if
(_sorted)
{
if
(sortField.Direction == ListSortDirection.Ascending &&
_previousGridColumnSortDirection == ListSortDirection.Descending)
{
_sorted =
false
;
radGridView1.MasterGridViewTemplate.SortDescriptors.Clear();
}
//Save the SortOrder for the next iteration
_previousGridColumnSortDirection = sortField.Direction;
}
else
{
_sorted =
true
;
_previousGridColumnSortDirection = sortField.Direction;
}
}
if
(e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.Add)
{
_sorted =
true
;
_previousGridColumnSortDirection = sortField.Direction;
}
}
}
catch
{
}
}
Hello,
I have Winform RadGridView with grouped columns header. I will wrap the long text.
radGridView1.AutoSizeRows = true;
radGridView1.Columns["column1"].WrapText = true;
radGridView1.Columns["column1"].Multiline = true;
Error after view definition, See picture in attach.
Without grouped columns header works well.
Any suggestions?
Regards,
Elek
#region GridDataCellElement
public
class
GridDataCustomCellElement : GridDataCellElement
{
#region Locals
private
RadImageButtonElement radButtonElementViewOrder;
private
RadImageButtonElement radButtonElementNewOrder;
public
GridViewColumn thisColumn;
public
GridRowElement thisRow;
#endregion
#region Constructors
public
GridDataCustomCellElement(GridViewColumn col, GridRowElement row) :
base
(col, row) { thisColumn = col; thisRow = row;}
#endregion
#region Events
void
radButtonElementNewOrder_Click(
object
sender, EventArgs e)
{
Main newOrder =
new
Main(GetFolderPath(thisRow.GridControl.CurrentRow.Cells[2].Value.ToString()) +
"\\"
+ thisRow.GridControl.CurrentRow.Cells[0].Value.ToString());
newOrder.MyParentForm = (SalesOrderingClient.Home)thisRow.GridControl.FindForm();
newOrder.IsCopyOrder =
true
;
newOrder.ShowDialog();
}
void
radButtonElementViewOrder_Click(
object
sender, EventArgs e)
{
// Build order object
SalesOrderingObjects.Order objOrder = SalesOrderingObjects.Order.LoadOrder(GetFolderPath(thisRow.GridControl.CurrentRow.Cells[2].Value.ToString()) +
"\\"
+ thisRow.GridControl.CurrentRow.Cells[0].Value.ToString());
// Build session object
Session s =
new
Session(objOrder);
// Display Order
Order o =
new
Order(s);
o.ShowDialog();
}
#endregion
#region Overrides
/// <summary>
/// Create new controls and add them to cell
/// </summary>
protected
override
void
CreateChildElements()
{
// Set up controls and add them to this cell
Home h =
new
Home();
radButtonElementViewOrder =
new
RadImageButtonElement();
radButtonElementViewOrder.ButtonFillElement.BackColor = Color.Transparent;
radButtonElementViewOrder.ButtonFillElement.BackColor2 = Color.Transparent;
radButtonElementViewOrder.ImageAlignment = ContentAlignment.MiddleRight;
radButtonElementViewOrder.BorderElement.Width = 0;
radButtonElementViewOrder.Image = h.IconImageLIst.Images[1];
radButtonElementViewOrder.ToolTipText =
"View Order"
;
this
.Children.Add(radButtonElementViewOrder);
radButtonElementNewOrder =
new
RadImageButtonElement();
radButtonElementNewOrder.ButtonFillElement.BackColor = Color.Transparent;
radButtonElementNewOrder.ButtonFillElement.BackColor2 = Color.Transparent;
radButtonElementNewOrder.ImageAlignment = ContentAlignment.MiddleRight;
radButtonElementNewOrder.BorderElement.Width = 0;
radButtonElementNewOrder.Image = h.IconImageLIst.Images[0];
radButtonElementNewOrder.ToolTipText =
"Copy Order"
;
this
.Children.Add(radButtonElementNewOrder);
radButtonElementNewOrder.Click +=
new
EventHandler(radButtonElementNewOrder_Click);
radButtonElementViewOrder.Click +=
new
EventHandler(radButtonElementViewOrder_Click);
}
/// <summary>
/// Set size and position of controls in the cell
/// </summary>
/// <param name="finalSize"></param>
/// <returns></returns>
protected
override
SizeF ArrangeOverride(SizeF finalSize)
{
// If there are more than 1 controls in this cell
//if (this.Children.Count == 3)
//{
// Setup dimensions and position and modifiy controls
RectangleF btn1 =
new
RectangleF(20, 12, 36, 36);
RectangleF btn2 =
new
RectangleF(58, 12, 36, 36);
this
.Children[0].Arrange(btn1);
this
.Children[1].Arrange(btn2);
//}
return
finalSize;
}
/// <summary>
/// Set the cells theme, if not done, cell does not inherit theme as it is custom
/// </summary>
protected
override
Type ThemeEffectiveType
{
get
{
return
typeof
(GridDataCellElement);
}
}
public
override
bool
IsCompatible(GridViewColumn data,
object
context)
{
return
data
is
RadLabelColumn && context
is
GridDataRowElement;
}
#endregion
#region Private Methods
/// <summary>
/// Get folder path based on XML status
/// </summary>
/// <param name="status"></param>
/// <returns></returns>
string
GetFolderPath(
string
status)
{
string
folder =
string
.Empty;
switch
(status)
{
case
"Saved"
:
folder = Common.SavedOrdersFolder;
break
;
case
"InProgress"
:
folder = Common.InProgressOrdersFolder;
break
;
case
"Sent"
:
folder = Common.SentOrdersFolder;
break
;
case
"Requested"
:
folder = Common.RequestedOrdersFolder;
break
;
default
:
folder = Common.UserDataBaseFolder;
break
;
}
return
folder;
}
#endregion
}
#endregion
protected
override
void
CreateChildElements()
{
// Set up controls and add them to this cell
Home h =
new
Home();
switch
(SOMETHING GOES HERE)
{
case
?:
radButtonElementViewOrder =
new
RadImageButtonElement();
radButtonElementViewOrder.ButtonFillElement.BackColor = Color.Transparent;
radButtonElementViewOrder.ButtonFillElement.BackColor2 = Color.Transparent;
radButtonElementViewOrder.ImageAlignment = ContentAlignment.MiddleRight;
radButtonElementViewOrder.BorderElement.Width = 0;
radButtonElementViewOrder.Image = h.IconImageLIst.Images[1];
radButtonElementViewOrder.ToolTipText =
"View Order"
;
this
.Children.Add(radButtonElementViewOrder);
radButtonElementNewOrder =
new
RadImageButtonElement();
radButtonElementNewOrder.ButtonFillElement.BackColor = Color.Transparent;
radButtonElementNewOrder.ButtonFillElement.BackColor2 = Color.Transparent;
radButtonElementNewOrder.ImageAlignment = ContentAlignment.MiddleRight;
radButtonElementNewOrder.BorderElement.Width = 0;
radButtonElementNewOrder.Image = h.IconImageLIst.Images[0];
radButtonElementNewOrder.ToolTipText =
"Copy Order"
;
this
.Children.Add(radButtonElementNewOrder);
radButtonElementNewOrder.Click +=
new
EventHandler(radButtonElementNewOrder_Click);
radButtonElementViewOrder.Click +=
new
EventHandler(radButtonElementViewOrder_Click);
break
;
case
?:
// ADD SOME DIFFERENT CONTROLS
break
;
}
}
public
partial
class
Form1 : Form
{
public
Form1()
{
InitializeComponent();
radPropertyGrid1.PropertyValueChanged +=
new
PropertyGridItemValueChangedEventHandler(radPropertyGrid1_PropertyValueChanged);
string
A =
""
;
int
B = 0;
bool
C =
false
;
RadPropertyStore store =
new
RadPropertyStore();
PropertyStoreItem itemA =
new
PropertyStoreItem(
typeof
(
string
),
"A"
, A);
PropertyStoreItem itemB =
new
PropertyStoreItem(
typeof
(
int
),
"B"
, B);
PropertyStoreItem itemC =
new
PropertyStoreItem(
typeof
(
bool
),
"C"
, C);
store.Add(itemA);
store.Add(itemB);
store.Add(itemC);
radPropertyGrid1.SelectedObject = store;
}
void
radPropertyGrid1_PropertyValueChanged(
object
sender,
PropertyGridItemValueChangedEventArgs e)
{
try
{
throw
new
NotImplementedException();
}
catch
(Exception exc)
{
MessageBox.Show(exc.Message);
}
}
}
Hi... im creating a RadListBox at runtime with a win app and it creates with the correct items but... I cant select any of them!!! =S... thats really weird and I've been trying many options... can you help me with that issue?
here's my code.
RadListBox
lista = new RadListBox();
for
(int j = 0; j < listaCuartoSel.Count; j++)
{
RadListBoxItem item = new RadListBoxItem();
item.Text = listaCuartoSel[j].Nombre;
string pathImagen = "ImagePath";
Image imagenCuarto = Image.FromFile(pathImagen);
item.Image = imagenCuarto;
item.Alignment =
ContentAlignment.TopLeft;
item.ImageAlignment =
ContentAlignment.MiddleRight;
item.TextImageRelation =
TextImageRelation.ImageBeforeText;
lista.Items.Add(item);
}
lista.Enabled =
true;
lista.Virtualized =
true;
lista.IsAccessible =
true;
lista.SelectedIndex = 0;
lista.Width = 300;
this
.Controls.Add(lista);