Thursday, April 10, 2014

Devexpress WPF how to make Buttons

In case you were wondering where ordinary buttons went in devexpress for WPF, here is an example of how to make one.

First, make sure to set the dxe namespace:

xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" 

then:

<dxe:ButtonEdit Height="23" Margin="195,137,0,0" Width="75" ShowText="False" AllowDefaultButton="False">
 <dxe:ButtonInfo Content="Cancel" Click="btnBack_Click" />
</dxe:ButtonEdit>

Wednesday, April 2, 2014

Devexpress WPF Gridview: set row cell font size

Quite simple, even though I couldn't find anything on that matter. Here's a complete example, giving you can locate the automatically created TableView element in your XAML:

<dxg:TableView Name="tableView1" 
   ShowGroupPanel="False" 
   NavigationStyle="Row" >
 <dxg:TableView.CellStyle>
  <Style>
   <Setter Property="TextElement.FontSize" Value="8" />
  </Style>
 </dxg:TableView.CellStyle>
</dxg:TableView>

Friday, March 21, 2014

Installshield LE: -4340: Internal Build Error, solved (somehow)

Thanks Flexera for the complete lack of support on this error... Well, my research had me understand the following:

  • The setup build crashes at a step which should write this in the log, but doesn't:
    Searching project for extract-at-build components...
  • It's component related (ocx?).
  • In my case, I have home made components (User Controls) in my project. They may be the cause.
  • In my case, it wasn't a dependency problem.
By repeatedly cleaning and rebuilding my projects individually, the error SOMEHOW went away. I couldn't control the problem so that's all the information I have. I hope it helps.

Tuesday, February 25, 2014

Visual Paradigm: Re-register

I'm using the Community Edition. I screwed up my email address when I tried to register so I never received the activation code. Here's what their kind support team told me to do so I can register again:

Remove the VisualParadigm folder located in %userprofile%\AppData\Local 

Start Visual Paradigm again and you should see the registration form again.

Friday, February 7, 2014

DevExpress MVC: Add an enum to a ComboBox

Here is a nice extension method I did to add an enum (text and values) to a DevExpress MVC ComboBox. it might also work with other kinds of widgets.

public static void AddEnum<TEnum>(this ListEditItemCollection instance)
 where TEnum : struct
{
 foreach (TEnum tos in (TEnum[])Enum.GetValues(typeof(TEnum)))
 {
  instance.Add(Enum.GetName(typeof(TEnum), tos), Convert.ToInt32(tos));
 }
}

Then I can do this:

Html.DevExpress().ComboBoxFor(model => model.OrderStatus,
 cbSettings =>
 {
  cbSettings.Properties.Items.AddEnum<Tag.TagOrderStatus>();
 }
).GetHtml();

the "struct" type constraint limits the type that can be used as the generic type, but won't limit it to only enums. Sh*t will hit the fan if something else that an enum is used, but it's a bit too complicated to apply a real functional compile time limit.

Have fun!

Monday, January 27, 2014

C# .Net: Get the value of a static property of a generic type

I did a base type for a singleton pattern and used a generic type later to refer to a inherited type. Here is how I got access to the Instance method:

instance = (T)typeof(T).GetProperty("Instance", BindingFlags.Static | BindingFlags.FlattenHierarchy | BindingFlags.Public).GetValue(null, new object[] { });

This will call the base class Instance property and return the singleton instance of the inherited T class.

It's a bit hard to explain in words... I still hope it helps someone ;)

Friday, December 6, 2013

T-SQL: Silent Select

Here is the solution I found on SO in its simplest form:

SELECT SomeField
INTO #tmpDevNull
FROM some_table

This will store the selected result in a temporary table that will simply be disposed at the end of the request.

You might also want to begin with:

SET NOCOUNT ON

So no "rows affected" message is shown.