We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Can I use grid control as ListBox?

Thread ID:

Created:

Updated:

Platform:

Replies:

89411 Aug 24,2009 05:22 AM UTC Aug 26,2009 11:34 AM UTC WinForms 3
loading
Tags: Tools
Allon
Asked On August 24, 2009 05:22 AM UTC

Hello, everyone

How can I simulate listbox with grid control? All I need is to make the rows as read only and the curser to be invisible as well. I did everything by myself beside all I mentioned about the cursor.

Thanks
Allon

Jisha Joy [Syncfusion]
Replied On August 25, 2009 06:51 AM UTC

Hi Allon,

Thank you for posting query to us.

The desired behavior can be achieved by setting the ReadOnly property to true and handling the CurrentCellStartEditing event. See the code:

this.gridControl1.ReadOnly = true;
this.gridControl1.CurrentCellStartEditing += new CancelEventHandler(gridControl1_CurrentCellStartEditing);

void gridControl1_CurrentCellStartEditing(object sender, CancelEventArgs e)
{
e.Cancel = true;
}

Please let me know if this helps.

Regards,
Jisha

Allon
Replied On August 25, 2009 11:13 AM UTC

Hi Jisha,

I'd like to thank you, for your quick reply, but I have one more thing to make it better. I'd like to know, how can I change background color of the selected row according to user selection with arrows (with something like grd.selectedrowindext). For now, I can change backcolor, only with grd_CellClick handler.

Thanks in advance
Allon


Lingaraj S [Syncfusion]
Replied On August 26, 2009 11:34 AM UTC

Hi Allon,

Thank you for the update.

If you want to select the row in GridControl, then please try using ListBoxSelectionMode property in GridControl to achieve this functionality.

Refer the code below:

#### C# code ####
this.gridControl1.ListBoxSelectionMode = SelectionMode.One;
// It is used to change the selection color
this.gridControl1.Model.Options.AlphaBlendSelectionColor = Color.Pink;
######## VB Code ###########
Me.gridControl1.ListBoxSelectionMode = SelectionMode.One
' It is used to change the selection color
Me.gridControl1.Model.Options.AlphaBlendSelectionColor = Color.Pink


GetSelectedRows method is used to get the selected row in GridControl.

Refer the code below:

#### C# code ####
GridRangeInfoList range = this.gridControl1.Model.Selections.GetSelectedRows(true, true);
MessageBox.Show(range[0].Top.ToString());
######## VB Code ###########
Dim range As GridRangeInfoList = Me.gridControl1.Model.Selections.GetSelectedRows(True, True)
MessageBox.Show(range(0).Top.ToString())


Please let me know if you have any queries.

Regards,
Lingaraj S.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;