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

Always the first record is selected. Help

39 Answers 647 Views
MultiColumn ComboBox
This is a migrated thread and some comments may be shown as answers.
francis
Top achievements
Rank 1
francis asked on 26 Nov 2010, 03:51 AM
Hello gentlemen, I need your help.

RadMultiColumnComboBox.

When full this control from the database the first record always appears in the dropdown before selecting it. I do not want the first row is positioned in the dropdow without select.

as I can do this?

you have a virtual chat?

39 Answers, 1 is accepted

Sort by
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 26 Nov 2010, 11:57 AM
Hello Francis,

I imagine that this is standard. May I ask what you want to happen if you do not want the first record to be selected?

In my view, all windows forms combo lists should have a value selected by default.
Look forward to hearing back from you
Richard
0
francis
Top achievements
Rank 1
answered on 26 Nov 2010, 01:48 PM
Hello Richard,

I think I am not understood well,

When this control is filled in the event of the upload form, I just want to fill the list that appears when the control is clicked. Because this is currently, which when filled also fills my dropdownlist ...

That's not what I want .... Please help me with this.
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 26 Nov 2010, 02:00 PM
Hi Francis,

I'm very sorry but I don't think I understand what you would like to do. Please can yuo post a screenshot or some code to demonstate and I will do my best to help you,.

Thanks
Richard
0
francis
Top achievements
Rank 1
answered on 26 Nov 2010, 02:33 PM
Hi Richard, this is how I want you to see when it is full, there I show an example
0
Richard Slade
Top achievements
Rank 2
answered on 26 Nov 2010, 02:40 PM
hello Francis,

In this case I would advise having an additional default item in your datasource with a blank value that you can validate against and not allow the user to go back to once they have picked a value.

However, this is not usual Windows Forms development practice and I'd say that usually in Windows development it would be best to always have an item selected, even if the value display value reads "No Value"

Let me know if you need more help
Richard
0
francis
Top achievements
Rank 1
answered on 26 Nov 2010, 02:50 PM
Richard Sorry I'm new using these controls, and may give you more questions ...

thank you very much ..
0
Richard Slade
Top achievements
Rank 2
answered on 26 Nov 2010, 03:06 PM
Hello,

That's no problem. Just ask anything you need and I'll be happy to help
Richard

p.s - please remember to mark answer in the forums when you get your answers so others can find the solution too.
Richard
0
francis
Top achievements
Rank 1
answered on 01 Dec 2010, 02:58 PM
Hi Richard,

as it is called the property to prevent the user type in the RadCombobox?
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 01 Dec 2010, 03:10 PM
Hello,

It's the DropDownStyle. E.g.

radMultiColumnComboBox.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList

Hope that helps
Richard
0
francis
Top achievements
Rank 1
answered on 01 Dec 2010, 03:47 PM
Heey!!! thank you very much....
0
Richard Slade
Top achievements
Rank 2
answered on 01 Dec 2010, 03:55 PM
No problem. Please remember to mark as answer in the forum those suggestions that have helped so others can find teh solution too.

Regards,
Richard
0
francis
Top achievements
Rank 1
answered on 06 Dec 2010, 02:33 PM
Richard, I'm using RadGridView, I can increase the height as the header of the column?

Thankyou for you help...
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 06 Dec 2010, 02:38 PM
Hello Francis,

To increase the Row Header height, you can use the following code:
Me.RadGridView1.TableElement.TableHeaderHeight = 50

hope that helps
Richard
0
francis
Top achievements
Rank 1
answered on 06 Dec 2010, 02:54 PM
Richard this gives me an error. I added a picture so I can help more easily.
0
Richard Slade
Top achievements
Rank 2
answered on 06 Dec 2010, 02:57 PM
Hello,

Apologies, you are using an order version. Please replace TableElement with GridElement.
hope that helps
Richard
0
francis
Top achievements
Rank 1
answered on 06 Dec 2010, 04:34 PM
Richard, in the same RadGridView I have a GridCheckBoxColumn then I want to make a condition to see if it is checked or not, I can access this column to see if this checked?

Sorry for inconvenience
0
Richard Slade
Top achievements
Rank 2
answered on 06 Dec 2010, 04:53 PM
Hello Francis,

At what point do you want to check this column? E.g - When you click on the cell?, when you click on another cell in the same row?, when you delete a row?

Please let me know and I'll do my best to help
Richard
0
francis
Top achievements
Rank 1
answered on 06 Dec 2010, 05:22 PM
Hi Richard, thanks for your reply. 

I see when I click a button on the form.
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 06 Dec 2010, 05:29 PM

Hello Francis,

If you want to get the value of all rows for a column then you must loop over the rows in the grid. For exmaple:

Private Sub RadButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadButton1.Click
    For Each row As GridViewRowInfo In Me.RadGridView1.Rows
        Console.WriteLine(row.Cells("ColumnNmae").Value.ToString())
    Next
End Sub

Hope that helps, and please remember to mark all previous answers.

thanks
Richard
0
francis
Top achievements
Rank 1
answered on 08 Dec 2010, 03:36 PM
Hello richard how are you?

Using RadGridview I right click on the rows and I get a menu, I would like to disable it or only show the option to delete. 
as I can do that?

Thanks
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 08 Dec 2010, 03:46 PM
Hello Francis,

If you want to disable it you can just use:
radGridView1.AllowCellContextMenu = false;
of if you want to remove other items except Delete you can just use:

private void radGridView1_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)
{
    if (e.ContextMenuProvider is GridDataCellElement)
    {
        for (int i = e.ContextMenu.Items.Count - 1; i >= 0; i--)
        {
            var item = e.ContextMenu.Items[i];
            if (item.Text.Contains("Delete"))
            {
                continue;
            }
 
            e.ContextMenu.Items.RemoveAt(i);
        }
    }
}
or VB:
Private Sub radGridView1_ContextMenuOpening(sender As Object, e As ContextMenuOpeningEventArgs)
    If TypeOf e.ContextMenuProvider Is GridDataCellElement Then
        For i As Integer = e.ContextMenu.Items.Count - 1 To 0 Step -1
            Dim item = e.ContextMenu.Items(i)
            If item.Text.Contains("Delete") Then
                Continue For
            End If
 
            e.ContextMenu.Items.RemoveAt(i)
        Next
    End If
End Sub

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

Best Regards,
Emanuel Varga
Telerik WinForms MVP
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 08 Dec 2010, 03:50 PM
Hello,

In order to show only the "delete row" item in the right click context menu on the RadGridView, please consider the following code

Private Sub RadGridView1_ContextMenuOpening(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.ContextMenuOpeningEventArgs) Handles RadGridView1.ContextMenuOpening
    If TypeOf e.ContextMenuProvider Is GridDataCellElement AndAlso TypeOf Me.RadGridView1.CurrentRow Is GridViewDataRowInfo Then
        For i As Integer = 0 To e.ContextMenu.Items.Count - 1
            If Not String.Equals(e.ContextMenu.Items(i).Text, "Delete Row") Then
                e.ContextMenu.Items(i).Visibility = Telerik.WinControls.ElementVisibility.Collapsed
            End If
        Next
    End If
End Sub


Hope that helps but let me know if you have any more questions
Richard
0
Richard Slade
Top achievements
Rank 2
answered on 08 Dec 2010, 03:58 PM
Hi Emanuel,

Hope you're well. Just a small point on your sample. You need to ensure that the current row is also typeof GridViewDataRowInfo as well otherwise it will affect the NewRow row as well.

All the best
Richard
0
Emanuel Varga
Top achievements
Rank 1
answered on 08 Dec 2010, 04:05 PM
Hello Richard,

I'm good, thanks, you? preparing for the holidays? lately it's been more quiet than usual.
Sorry i can't be more active lately... deadlines...

Regarding the thread, that was whole point, on the new row there is no delete item, so if you remove all the items => no context menu will be shown for the new row, from what i understood this is the expected behavior, or did i misunderstood something?

Best Regards,
Emanuel Varga
Telerik WinForms MVP
0
Richard Slade
Top achievements
Rank 2
answered on 08 Dec 2010, 04:14 PM
Hi Emanuel,
I'm not prepared for the holidays at all yet. I always seem to leave it until the last moment. Still. A small break with my wife's family in Spain will be very welcome! :o)

I was under the impression this was just for the main data rows, but at least this way Francis has both options.

Francis - I hope these answers help you. If you need more information, please just let me know.

Thanks
All the best
Richard
0
francis
Top achievements
Rank 1
answered on 08 Dec 2010, 04:38 PM
Hey thank you very much friends, I never would not have done it without you. but I miss something. when I press delete row need to call a method like I do?
0
Richard Slade
Top achievements
Rank 2
answered on 08 Dec 2010, 04:41 PM
hi francis,

Please try this.

Private Sub RadGridView1_ContextMenuOpening(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.ContextMenuOpeningEventArgs) Handles RadGridView1.ContextMenuOpening
    If TypeOf e.ContextMenuProvider Is GridDataCellElement AndAlso TypeOf Me.RadGridView1.CurrentRow Is GridViewDataRowInfo Then
        For i As Integer = 0 To e.ContextMenu.Items.Count - 1
            If Not String.Equals(e.ContextMenu.Items(i).Text, "Delete Row") Then
                e.ContextMenu.Items(i).Visibility = Telerik.WinControls.ElementVisibility.Collapsed
            Else
                RemoveHandler e.ContextMenu.Items(i).Click, AddressOf Delete_Click
                AddHandler e.ContextMenu.Items(i).Click, AddressOf Delete_Click
            End If
        Next
    End If
End Sub
Private Sub Delete_Click(ByVal sender As Object, ByVal e As EventArgs)
    MessageBox.Show("Delete " & Me.RadGridView1.CurrentRow.Index.ToString())
End Sub

Hope that helps
Richard

EDIT// apologies.. you dont need
RemoveHandler e.ContextMenu.Items(i).Click, AddressOf Delete_Click
0
francis
Top achievements
Rank 1
answered on 08 Dec 2010, 05:08 PM
Hi, 

I said that index is not a member CurrentRow, Richard in that event I would like to know which row the user did click


0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 08 Dec 2010, 05:27 PM
Hi,

Apologies, my post was a little misleading.
This will give you the index of the row that was deleted. Or you can change the index property to any of the row properties that you need

Private m_Index As Integer
Private Sub RadGridView1_ContextMenuOpening(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.ContextMenuOpeningEventArgs) Handles RadGridView1.ContextMenuOpening
    If TypeOf e.ContextMenuProvider Is GridDataCellElement AndAlso TypeOf Me.RadGridView1.CurrentRow Is GridViewDataRowInfo Then
        For i As Integer = 0 To e.ContextMenu.Items.Count - 1
            If Not String.Equals(e.ContextMenu.Items(i).Text, "Delete Row") Then
                e.ContextMenu.Items(i).Visibility = Telerik.WinControls.ElementVisibility.Collapsed
            Else
                m_Index = Me.RadGridView1.CurrentRow.Index
                AddHandler e.ContextMenu.Items(i).Click, AddressOf Delete_Click
            End If
        Next
    End If
End Sub
Private Sub Delete_Click(ByVal sender As Object, ByVal e As EventArgs)
    MessageBox.Show("Deleted " & m_Index.ToString())
End Sub
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 08 Dec 2010, 05:32 PM
Hi,

You can also use the UserDeletingRow event as below
Private Sub RadGridView1_UserDeletingRow(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.GridViewRowCancelEventArgs) Handles RadGridView1.UserDeletingRow
    If MessageBox.Show("Are you sure you want to delete this row?", Me.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
        MessageBox.Show(e.Rows(0).Index.ToString())
    Else
        e.Cancel = True
    End If
End Sub

Richard
0
francis
Top achievements
Rank 1
answered on 08 Dec 2010, 07:23 PM
Sorry Richard error even cause me, I say the same. I added an attached image of error.

I hope you....
0
francis
Top achievements
Rank 1
answered on 08 Dec 2010, 07:24 PM
Sorry Richard error even cause me, I say the same. I added an attached image of error.

I hope you....
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 08 Dec 2010, 07:45 PM
Here you go Francis.

It's because you are using an older version, but it is still best to use the UserDeletingRow and UserDeletedRow as above.
Here is a sample

Private Sub RadGridView1_ContextMenuOpening(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.ContextMenuOpeningEventArgs) Handles RadGridView1.ContextMenuOpening
    If TypeOf e.ContextMenuProvider Is GridDataCellElement AndAlso TypeOf Me.RadGridView1.CurrentRow Is GridViewDataRowInfo Then
        For i As Integer = 0 To e.ContextMenu.Items.Count - 1
            If Not String.Equals(e.ContextMenu.Items(i).Text, "Delete Row") Then
                e.ContextMenu.Items(i).Visibility = Telerik.WinControls.ElementVisibility.Collapsed
            End If
        Next
    End If
End Sub
Private Sub RadGridView1_UserDeletingRow(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.GridViewRowCancelEventArgs) Handles RadGridView1.UserDeletingRow
    If MessageBox.Show("Are you sure you want to delete this row?", Me.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
        MessageBox.Show("Deleting Row Index: " & e.Rows(0).Index.ToString())
    Else
        e.Cancel = True
    End If
End Sub
Private Sub RadGridView1_UserDeletedRow(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.GridViewRowEventArgs) Handles RadGridView1.UserDeletedRow
    MessageBox.Show("Deleted Row")
End Sub

Let me know if you have any more questions ot comments
Richard
0
francis
Top achievements
Rank 1
answered on 08 Dec 2010, 08:06 PM
I understand perfectly. but my version does not have this event, "UserDeletingRow"  I sorry.

Richard, all I want is to know the number of the row that the user either delete the row 0, row 1, row 2 or 3. 

I think we're close to doing .... 

thank you very much for your help. 
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 08 Dec 2010, 08:34 PM
Hi Francis,

Apologies, I don't have these older versions to try out these things on, but could you try this then please. I think this will do it.

Private m_Index As Integer
Private Sub RadGridView1_ContextMenuOpening(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.ContextMenuOpeningEventArgs) Handles RadGridView1.ContextMenuOpening
    If TypeOf e.ContextMenuProvider Is GridDataCellElement AndAlso TypeOf Me.RadGridView1.CurrentRow Is GridViewDataRowInfo Then
        For i As Integer = 0 To e.ContextMenu.Items.Count - 1
            If Not String.Equals(e.ContextMenu.Items(i).Text, "Delete Row") Then
                e.ContextMenu.Items(i).Visibility = Telerik.WinControls.ElementVisibility.Collapsed
            Else
                m_Index = Me.RadGridView1.MasterGridViewTemplate.CurrentRow.Index
                AddHandler e.ContextMenu.Items(i).Click, AddressOf DeleteRow_Clicked
            End If
        Next
    End If
End Sub
Private Sub DeleteRow_Clicked(ByVal sender As Object, ByVal e As EventArgs)
    MessageBox.Show("Deleted: " & m_Index.ToString())
End Sub

All the best
Richard
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 08 Dec 2010, 08:40 PM
Hello again guys,

Francis, you can use the RowsChanging event and check for remove action, like so:
void radGridView1_RowsChanging(object sender, GridViewCollectionChangingEventArgs e)
{
    if (e.Action == NotifyCollectionChangedAction.Remove)
    {
        var rowsToBeRemoved = e.NewItems;
    }
}

or again VB:
Private Sub radGridView1_RowsChanging(sender As Object, e As GridViewCollectionChangingEventArgs)
    If e.Action = NotifyCollectionChangedAction.Remove Then
        Dim rowsToBeRemoved = e.NewItems
    End If
End Sub
because i still don't know the language of this thread...

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

Best Regards,
Emanuel Varga

Telerik WinForms MVP

0
francis
Top achievements
Rank 1
answered on 08 Dec 2010, 09:58 PM
Hey guys thank you very much but I've been ... 

use this code "Me.GvData.CurrentRow.Cells (0). Value" for the record and then know the number of the row of the grid. 


thank you very much. it is advisable to publish this conversation to help others ... 
0
Richard Slade
Top achievements
Rank 2
answered on 08 Dec 2010, 10:03 PM
Hi Francis,

I thought you said you couldn't use CurrentRow? Anyway, I'm glad you have this working. Please remember to mark all helpful posts as answer so others find the solution too.

Thanks
Richard
0
Stefan
Telerik team
answered on 09 Dec 2010, 03:15 PM
Hi francis, 

Thank you for writing.

The desired behavior can be achieved by setting the SelectedItem property of RadMultiColumnComboBox to null:
radMultiColumnComboBox1.SelectedItem = null;

I hope this information addresses your question. If there is anything else I can assist you with, do not hesitate to contact me.
 
Sincerely yours,
Stefan
the Telerik team
Get started with RadControls for WinForms with numerous videos and detailed documentation.
Tags
MultiColumn ComboBox
Asked by
francis
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
francis
Top achievements
Rank 1
Emanuel Varga
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or