This is a migrated thread and some comments may be shown as answers.

call from select row radgridview

5 Answers 215 Views
GridView
This is a migrated thread and some comments may be shown as answers.
jonathan
Top achievements
Rank 1
jonathan asked on 29 Oct 2010, 08:33 PM
hi could help me
as calling a window from
by selecting a row in radgridview

when selecting a row to me there will be a window

5 Answers, 1 is accepted

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 29 Oct 2010, 09:22 PM
Hello Jonathan,

I would suggest you do this just on CellDoubleClick, it could be very hard to understand what's happening if every time the user selects a new row, a new form is opening...

Either way you can decide for yourself, for the first option, which i recommend, you have to register for the CellDoubleClick event and use code similar to this:
void radGridView1_CellDoubleClick(object sender, GridViewCellEventArgs e)
{
    if (radGridView1.CurrentCell == null)
    {
        return;
    }
 
    var selectedRow = radGridView1.CurrentCell.RowInfo;
 
    var childForm = new Form1();
    childForm.ShowDialog();
}

For the second option, you can register to the CurrentRowChanged event and again do something similar to this:
void radGridView1_CurrentRowChanged(object sender, CurrentRowChangedEventArgs e)
{
    var row = e.CurrentRow;
    var childForm = new Form1();
    childForm.ShowDialog();
}
*child form is the name of the form you want to create when the user double clicks the cell or changes the current row.

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga
0
jonathan
Top achievements
Rank 1
answered on 29 Oct 2010, 09:32 PM
hola emanuel.
mi duda es la siguiente

pero para vbnet

lo que quiero hacer es lo siguiente
que al momento de selecionar una fila, en la que la celda principal es id
al darle click o dobleclick o un evento keydown
se me habra la ventana que ya tengo predeterminada

y que tome la id de la fila que ala selecionado

ejemplo anteriormente con el componente janusgrid podia hacerlo pero quise cambiar a telerik
pero en este aun no puedo

este es mi ejemplo como lo hacia antes y como podria hacerle en radgridview

If e.KeyCode = Keys.F5 Then
            For x As Integer = 0 To gestoria.RowCount - 1
                gestoria.Row = x
                If gestoria.GetValue(0).ToString() = "True" Then
                    Dim Query As New access
                    Query.AgregarParametro("@clave_elector", gestoria.GetValue(1).ToString())
 
                    Query.ExecuteNonQuery("SELECT clave_elector FROM tbln WHERE clave_elector = @clave_elector")
 
                    add_gestoria.clave_elector.Text = gestoria.GetValue(1).ToString()
 
                End If
            Next
            add_gestoria.Show()
 
        End If
0
Emanuel Varga
Top achievements
Rank 1
answered on 29 Oct 2010, 09:52 PM
Hello again,

Sorry... can't speak Spanish :(, but i can use google translate, so:

Do you want to call the other form when F5 is pressed?
 
0
jonathan
Top achievements
Rank 1
answered on 29 Oct 2010, 09:53 PM
hola emanuel.
my question is this

but for vbnet

I want to do is the following
that when selecting a row in which the main cell id
to give click or doubleclick or keydown event
there will be me that I have the default window

and take the id of the row to SELECTED

previously such janusgrid component could do but I wanted to change telerik
but this I can not even

this is my example as I did before and how it could make in radgridview

Imagen


I show the image is made with the component DataGridView janus
Select a row to
and press F5 I'll be the window with the selected row data

in RadGridView I have not been able to solve

the code that I showed you above is the component janusgrid

but with the componene of RadGridView

how could it




0
Svett
Telerik team
answered on 04 Nov 2010, 09:57 AM
Hi jonathan,

You need to create a custom behavior where you can handle your scenario. You can use the following code snippet as a sample:

public class CustomGridBehavior : BaseGridBehavior
{
    public override bool ProcessKey(KeyEventArgs keys)
    {
        if (keys.KeyCode == Keys.F5 &&
            !this.GridViewElement.IsInEditMode &&
            this.GridViewElement.CurrentRow != null)
        {
            using (Form form = new Form())
            {
                form.ShowDialog();
            }
 
            return true;
        }
 
        return base.ProcessKey(keys);
    }
}

Finally, you need to replace the default behavior by setting the GridBehavior property:
this.radGridView1.GridBehavior = new CustomGridBehavior();

Sincerely yours,
Svett
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
jonathan
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
jonathan
Top achievements
Rank 1
Svett
Telerik team
Share this question
or