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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Lookup cell using databound grid

Thread ID:





20257 Oct 13,2004 11:48 AM UTC Oct 13,2004 03:18 PM UTC WinForms 5
Tags: GridControl
John Wood
Asked On October 13, 2004 11:48 AM UTC

I have a currency cell that is a lookup into another table. The currency may be 15 for example, but I want it to display USD by looking that up in another table. This works fine if I make the cell a combobox and set the source to the currency table, and the display member to CurrencyName. However, I don''t want the grid to be editable. I don''t want it to drop down or be editable, but I do want it to select the row if the cell is clicked (so disabling it is out of the question). Anyone know what I can do? Maybe it should be a formula cell instead (can they do lookups?). Thanks! John

Administrator [Syncfusion]
Replied On October 13, 2004 01:48 PM UTC

Probably the simplest things is to just use the combobox that works for you now and hide the button. You can make it readonly so it cannot be changed or disable it so it cannot be clicked. To hide the button, set style.ShowButton = GridShowButton.Hide for the column. For ReadOnly, set style.ReadOnly = true. To disable it, set style.Enabled = false.

John Wood
Replied On October 13, 2004 02:09 PM UTC

There''s no other way to have a column ''lookup'' to another table and show a different field? Isn''t that a really common scenario for normalized tables? I''m surprised it''s not possible to have a static field that does that. Can I have a formula lookup in another table in the dataset?

Administrator [Syncfusion]
Replied On October 13, 2004 02:40 PM UTC

The GridGroupingControl supports this type of celltype, but it is not currently available in GridDataBoundGrid as it relies on technology only available through the grouping engine. Our Formula engine currently does not support VLookUp and HLookUp. But it is straight forward to create your own custom formula which could do specific lookups. But using formula cells in a GridDataBoundGrid requires additional work as this type of grid does not store cell specific styles. (There is a KB on this.) It can be done, but would take addition coding. Another option is to handle the grid.DrawCellDisplayText event. There you can catch the foreign key value and swap it for the proper display value. Directly using the ComboBox celltype is the simplest way to do it. You could do what you want by setting its properties. If you want a celltype that does this, you could derive a celltype from the combobox celltype, hide its button and make sure it never becomes editable if you want a celltype to do explicitly this look up. But, you can effectively do the same thing with the existing ComboBox celltype just setting properties.

John Wood
Replied On October 13, 2004 02:47 PM UTC

Yes a disabled combobox does do exactly what I need... the only problem is that you can no longer select the row when you click that disabled cell, which becomes a usability issue and difficult to explain to users. Thanks for your help though.

Administrator [Syncfusion]
Replied On October 13, 2004 03:18 PM UTC

Do you have grid.ListBoxSelectionMode set to do the row selections? If so, then handling the grid''s MouseDown would allow you to select the row at that point.
private void gridDataBoundGrid1_MouseDown(object sender, MouseEventArgs e)
	int row, col;
	Point pt = new Point(e.X, e.Y);
	int disabledCol = this.gridDataBoundGrid1.Binder.NameToColIndex("Col1");
	if(this.gridDataBoundGrid1.PointToRowCol(pt, out row, out col, -1)
		&& 	col == disabledCol)
		this.gridDataBoundGrid1.CurrentCell.MoveTo(row, 1); //assumes 1 is not disabled


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon