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

WinForms linklabel custom control issue

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

11 Replies

LS Lingaraj S Syncfusion Team October 8, 2009 01:05 PM UTC

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.


VN Vidya Nara October 8, 2009 02:37 PM UTC

Hi Lingaraj,

Thanks a lot, the solution works really well.

regards,
Vidya


LS Lingaraj S Syncfusion Team October 9, 2009 06:41 AM UTC

Hi Vidya,

Thank you for the update.

Please let me know if it helps.

Regards,
Lingaraj S.


VN Vidya Nara October 12, 2009 10:37 PM UTC

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


JJ Jisha Joy Syncfusion Team October 13, 2009 09:21 AM UTC

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


VN Vidya Nara October 13, 2009 08:26 PM UTC

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


JJ Jisha Joy Syncfusion Team October 15, 2009 11:12 AM UTC

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


VN Vidya Nara October 16, 2009 07:28 PM UTC

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


LS Lingaraj S Syncfusion Team October 19, 2009 01:40 PM UTC

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.


VN Vidya Nara October 19, 2009 08:50 PM UTC

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

regards,
Vidya


LS Lingaraj S Syncfusion Team October 20, 2009 10:12 AM UTC

Hi Vidya,

Thank you for the update.

We will wait to hear from you.

Regards,
Lingaraj S.

Loader.
Live Chat Icon For mobile
Up arrow icon