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.
Unfortunately, activation email could not send to your email. Please try again.

WinForms linklabel custom control issue

Thread ID:

Created:

Updated:

Platform:

Replies:

90561 Oct 7,2009 01:48 PM Oct 20,2009 06:12 AM Windows Forms 11
loading
Tags: Grouping
Vidya Nara
Asked On October 7, 2009 01:48 PM

Hi,

I am using a custom control (WinForms Linklabel control) for a celltype in gridgroupingcontrol. According to the picturebox example that comes with syncfusion, I have defined three classes:
MyCellModel, MyCellRenderer and MyCellProperties.

I am able to add links to the linklabel control and it works fine when I set a custom property in the MyCellProperties class in the Form_Load method. The custom property takes the list of links to be displayed.

However, when I try to set the same custom property with a different list of links in the QueryCellStyleInfo, it resets the list of URLs but does not associate the eventhandlers to the link.As a result, in the UI, the new set of links are displayed but they are not clickable.

I have attached a zipped version of my code,could you please suggest what is missing?


Thanks & regards,
Vidya



My Project_f7e6322e.zip

Lingaraj S [Syncfusion]
Replied On October 8, 2009 09:05 AM

Hi Vidya,

Thank you for your interest in Syncfusion products.

If you want to set the CustomControl in GridGroupingControl cell, then please try using “Control” cell type in GridGroupingControl cell to achieve your requirement as shown below:

private void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e)
{
if ((e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell || e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell)&& e.TableCellIdentity.Column != null && e.TableCellIdentity.Column.Name == "col1")
{
e.Style.CellType = "Control";
// Please try to apply you custom control here
e.Style.Control = customcontrol;
}
}


Refer the modified sample from below link:
http://files.syncfusion.com/support/samples/Grid.Windows/7.3.0.20/Forums/Project_Mod.zip

Please let me know if you have any queries.

Regards,
Lingaraj S.

Vidya Nara
Replied On October 8, 2009 10:37 AM

Hi Lingaraj,

Thanks a lot, the solution works really well.

regards,
Vidya

Lingaraj S [Syncfusion]
Replied On October 9, 2009 02:41 AM

Hi Vidya,

Thank you for the update.

Please let me know if it helps.

Regards,
Lingaraj S.

Vidya Nara
Replied On October 12, 2009 06:37 PM

Hi,


A cell type of "Control" does not resize to fit the contents. I am handling it in the gridGroupingControl1_TableControlCellDrawn method.

The grid grouping control that I am using is being resizedtofit on the rows.

Please find attached a sample example. I have three columns. The first column is of static type, it resizes to fit the contents.


The third column is of Linklabel "Control" cell type. the resize to refit, does not work on this column.
Can you please suggest a way of making it work?

Thank you.

regards,
Vidya



My Project_336a0fd9.zip

Jisha Joy [Syncfusion]
Replied On October 13, 2009 05:21 AM

Hi Vidya,

Please refer the following sample from our sample browser, that illustrates the automatic resizing of grid cells depending on the size of custom controls placed inside cells.

C:\documents and settings\{username}\my documents\syncfusion\essentialstudio\{version}\Windows\Grid.Windows\Samples\2.0\Grid Layout\Custom Cell Autosizing Demo\cs

Please try this and let me know if this helps.

Regards,
Jisha

Vidya Nara
Replied On October 13, 2009 04:26 PM

Hi Jisha,

I have looked at the example. In the example, gridcontrol is being used, the size of the custom control is constant for all the rows (hence the size is being set inside the custom control class) and the resizetofit() is being called in the form_load.

In my example (attached with my previous post),

a) I am using a gridgroupingcontrol.

b) The size of the custom control will vary for each row as the custom control that I am using (linklabel) will contain different number of links for each row(based on the datasource for that row), so I have to set the size in the gridGroupingControl1_TableControlDrawCell event handler.

c)I do not have a form_load method. So I am calling the resizetofit() in the gridGroupingControl1_TableControlCellDrawn event handler. As shown in the sample, it is resizing to fit the column 1 contents( static text) but does not consider the new height for the linklabel once its height is manipulated and set in gridGroupingControl1_TableControlDrawCell event handler.


Would it be possible for you to take a look at the sample and suggest what I am missing please.

Thank you.

regards,
Vidya

Jisha Joy [Syncfusion]
Replied On October 15, 2009 07:12 AM

Hi Vidya,

You need to handle QueryRowHeight event to achieve the desire behavior. Please find the modified sample to get this work.


Regards,
Jisha



My Project_f7e81469.zip

Vidya Nara
Replied On October 16, 2009 03:28 PM

Thank you for taking a look at the code. That might not work for me as I need to access the underlying control for its size when setting the row height.

Vidya

Lingaraj S [Syncfusion]
Replied On October 19, 2009 09:40 AM

Hi Vidya,

Thank you for the update.

Please try using below way to set the individual RowHeight for GridGroupingControl based on DataSource value.

void TableModel_QueryRowHeight(object sender, GridRowColSizeEventArgs e)
{
GridTableCellStyleInfo sty = this.gridGroupingControl1.TableControl.GetTableViewStyleInfo(e.Index, 0);
if (sty.TableCellIdentity.DisplayElement.Kind == Syncfusion.Grouping.DisplayElementKind.Record)
{
Record rec = sty.TableCellIdentity.DisplayElement.GetRecord();
if (rec != null)
{
// try get a value through property
// try use the below code to get a value
int links=rec.GetValue(fieldname);
// try using your calculation count below
e.Size = 25 * links;
e.Handled = true;
}
}
}


Please let me know if you have any queries.

Regards,
Lingaraj S.

Vidya Nara
Replied On October 19, 2009 04:50 PM

Thanks for the alternative. I will try it and post an update.

regards,
Vidya

Lingaraj S [Syncfusion]
Replied On October 20, 2009 06:12 AM

Hi Vidya,

Thank you for the update.

We will wait to hear from you.

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.

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.

;