0
I have the following situation. A Usercontrol where I can choose a company to work, when I choose, I send it to the application title.
My problem is that I can only choose the company with just one click, but I would like to select with double click.
Inside of my Gridcontrol:
<dxg:GridControl x:Name="grid" AutoGenerateColumns="None" EnableSmartColumnsGeneration="True" dxlc:LayoutControl.AllowVerticalSizing="True"
ItemsSource="{Binding Empresas, RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}}"
SelectedItem="{Binding EmpresaSelecionada, Mode=TwoWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}}" PreviewMouseDoubleClick="grid_PreviewMouseDoubleClick" PreviewKeyDown="grid_PreviewKeyDown"
>
<dxg:GridControl.View>
<dxg:TableView x:Name="view" AutoWidth="True" AllowPerPixelScrolling="True" ShowGroupPanel="False" AllowEditing="False"/>
</dxg:GridControl.View>
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="Id" Width="30"/>
<dxg:GridColumn FieldName="Cnpj" Header="CNPJ / CPF"/>
<dxg:GridColumn FieldName="RazaoSocial"/>
<dxg:GridColumn FieldName="Municipio" Header="Cidade"/>
<dxg:GridColumn FieldName="Logradouro" Header="Endereço"/>
<dxg:GridColumn FieldName="Situacao" />
</dxg:GridControl.Columns>
</dxg:GridControl>
Code:
public partial class U_EscolherEmpresa : UserControl
{
List<DC_System.Model.Empresa> str = new List<DC_System.Model.Empresa>();
public static readonly DependencyProperty EmpresaSelecionadaProperty =
DependencyProperty.Register("EmpresaSelecionada", typeof(DC_System.Model.Empresa), typeof(U_EscolherEmpresa), new PropertyMetadata(null));
public DC_System.Model.Empresa EmpresaSelecionada
{
get { return this.GetValue(EmpresaSelecionadaProperty) as DC_System.Model.Empresa; }
set { this.SetValue(EmpresaSelecionadaProperty, value); }
}
private void AddToList()
{
using (EmpresaController controller = new EmpresaController())
{
foreach (DataRow row in controller.ListarEscolherEmpresa(2).Rows)
{
var obj = new DC_System.Model.Empresa()
{
Id = (int)row.ItemArray[0],
Cnpj = (string)row.ItemArray[1],
RazaoSocial = (string)row.ItemArray[2],
Municipio = (string)row.ItemArray[3],
Logradouro = (string)row.ItemArray[4],
Situacao = (bool)row.ItemArray[5],
};
str.Add(obj);
}
}
grid.ItemsSource = str;
}
public List<DC_System.Model.Empresa> Empresas
{
get
{
return str;
}
}
public U_EscolherEmpresa()
{
InitializeComponent();
AddToList();
}
private void grid_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
{
//O QUE COLOCAR AQUI? OU SE É AQUI...
}
I tried to add a Mousedoubleclick event but don’t know how to do it. Can anyone help me?
Thanks!
Dude, put in the whole code of yours
UserControl
– Jéf Bueno
I put everything, including my Social Event
– Emerson
Where is the click code?
– Jéf Bueno
There is no event for him.
– Emerson