Always the first record is selected. Help

40 posts, 12 answers
  1. francis
    francis avatar
    21 posts
    Member since:
    Oct 2010

    Posted 25 Nov 2010 Link to this post

    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?
  2. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 26 Nov 2010 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. francis
    francis avatar
    21 posts
    Member since:
    Oct 2010

    Posted 26 Nov 2010 Link to this post

    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.
  5. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 26 Nov 2010 Link to this post

    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
  6. francis
    francis avatar
    21 posts
    Member since:
    Oct 2010

    Posted 26 Nov 2010 Link to this post

    Hi Richard, this is how I want you to see when it is full, there I show an example
  7. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 26 Nov 2010 Link to this post

    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
  8. francis
    francis avatar
    21 posts
    Member since:
    Oct 2010

    Posted 26 Nov 2010 Link to this post

    Richard Sorry I'm new using these controls, and may give you more questions ...

    thank you very much ..
  9. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 26 Nov 2010 Link to this post

    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
  10. francis
    francis avatar
    21 posts
    Member since:
    Oct 2010

    Posted 01 Dec 2010 Link to this post

    Hi Richard,

    as it is called the property to prevent the user type in the RadCombobox?
  11. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 01 Dec 2010 Link to this post

    Hello,

    It's the DropDownStyle. E.g.

    radMultiColumnComboBox.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList

    Hope that helps
    Richard
  12. francis
    francis avatar
    21 posts
    Member since:
    Oct 2010

    Posted 01 Dec 2010 Link to this post

    Heey!!! thank you very much....
  13. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 01 Dec 2010 Link to this post

    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
  14. francis
    francis avatar
    21 posts
    Member since:
    Oct 2010

    Posted 06 Dec 2010 Link to this post

    Richard, I'm using RadGridView, I can increase the height as the header of the column?

    Thankyou for you help...
  15. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 06 Dec 2010 Link to this post

    Hello Francis,

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

    hope that helps
    Richard
  16. francis
    francis avatar
    21 posts
    Member since:
    Oct 2010

    Posted 06 Dec 2010 Link to this post

    Richard this gives me an error. I added a picture so I can help more easily.
  17. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 06 Dec 2010 Link to this post

    Hello,

    Apologies, you are using an order version. Please replace TableElement with GridElement.
    hope that helps
    Richard
  18. francis
    francis avatar
    21 posts
    Member since:
    Oct 2010

    Posted 06 Dec 2010 Link to this post

    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
  19. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 06 Dec 2010 Link to this post

    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
  20. francis
    francis avatar
    21 posts
    Member since:
    Oct 2010

    Posted 06 Dec 2010 Link to this post

    Hi Richard, thanks for your reply. 

    I see when I click a button on the form.
  21. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 06 Dec 2010 Link to this post

    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
  22. francis
    francis avatar
    21 posts
    Member since:
    Oct 2010

    Posted 08 Dec 2010 Link to this post

    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
  23. Answer
    Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 08 Dec 2010 Link to this post

    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
  24. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 08 Dec 2010 Link to this post

    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
  25. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 08 Dec 2010 Link to this post

    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
  26. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 08 Dec 2010 Link to this post

    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
  27. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 08 Dec 2010 Link to this post

    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
  28. francis
    francis avatar
    21 posts
    Member since:
    Oct 2010

    Posted 08 Dec 2010 Link to this post

    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?
  29. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 08 Dec 2010 Link to this post

    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
  30. francis
    francis avatar
    21 posts
    Member since:
    Oct 2010

    Posted 08 Dec 2010 Link to this post

    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


  31. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 08 Dec 2010 Link to this post

    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
Back to Top
UI for WinForms is Visual Studio 2017 Ready