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

GGC column with static text and hyperlinks

I am facing the following issues while using a GridGrouping Control.

1.) The Gridgrouping Control is data bound to an object. It has a column that should display text(static and hyperlinks). There can be more than one hyperlink in a row, referring to docs that have a Web URL.

These are the solutions I have tried:

- When I declare the cell type as Rich-text, the http URLs show up as hyperlinks but when clicked, they do not open up in a browser window.
- I tried declaring the cell type as “LinkLabel”, the custom cell type. It works when the column has only hyperlinks. Not when they have Static text and hyperlinks.
- The Gridgroupingcontrol has been made to auto size the rows based on the contents of this column. It’s being handled in the TableControlCellDrawn event handler. Auto sizing works when I make the column cell type as "Static". Does not seem to work when I make it as "Rich text" or any other custom cell type such as "LinkLabel".

Can anyone please suggest a way of making a column have static text as well as hyperlinks and when a hyperlink is clicked the corresponding document opens in a browser window while also having the auto sizing of the rows.



2.) There is another column with cell type as Combo-box. When the rows are auto sized, the combo-box also expands to fill the row width. Is there a way I can control the size of the combo-box? This column is also data bound to a field in the Object.

Thanks & regards,
Vidya

11 Replies

JJ Jisha Joy Syncfusion Team September 11, 2009 05:05 AM UTC

Hi Vidya,

Thank you for your interest in Syncfusion products.

1. Please refer the following sample that allows hyperlinks in grid cells and when a hyperlink is clicked the corresponding page opens in a browser window.

SampleLink

2. You can change the size of the combobox by changing the ButtonBarSize property of the Grid ComboBox cell model. See the code:


//Getting the combobox cellmodel
GridComboBoxCellModel model = this.gridGroupingControl1.TableModel.CellModels["ComboBox"] as GridComboBoxCellModel;
//change the size of the combobox button
model.ButtonBarSize = new Size(12, 12);



Please let me know if this helps.

Regards,
Jisha


VN Vidya Nara September 11, 2009 03:28 PM UTC

Hi Jisha,

Thanks for the prompt response. How can I make a cell have links as well as static text. Eg: Comply with link[Time Requirements]

Thanks,
Vidya


RC Rajadurai C Syncfusion Team September 15, 2009 02:35 PM UTC

Hi Vidya,

Thanks for your update.

To set different celltype texts in same cell, there is no property settings available. You would have to handle events like DrawCell to draw the required text splitting the cellrectangle. Here is some code for your reference.

this.gridGroupingControl1.TableControlDrawCell += new GridTableControlDrawCellEventHandler(gridGroupingControl1_TableControlDrawCell);

void gridGroupingControl1_TableControlDrawCell(object sender, GridTableControlDrawCellEventArgs e)
{
if (e.Inner.RowIndex >= 4 && e.Inner.ColIndex == 2)
{
string s = "Click";
e.Inner.Cancel = true;
Rectangle rect = e.Inner.Bounds;
rect.Location = new Point(rect.X, rect.Y);
rect.Size = new Size(35, 20);
e.Inner.Renderer.Draw(e.Inner.Graphics, e.Inner.Bounds, e.Inner.RowIndex, e.Inner.ColIndex, e.Inner.Style);
e.Inner.Graphics.DrawString(s, e.Inner.Style.GdipFont, new SolidBrush(e.Inner.Style.TextColor), rect);
}
}


Regards,
Rajadurai


VN Vidya Nara September 16, 2009 10:17 PM UTC

Hi,

1. ) I have a grouping grid control with vertical and horizontal scroll bars enabled. When the user re-sizes the parent window, how can I auto size the columns of the grouping grid proportionately? I am looking for a property similar to datagridviewcolumn1.autosizemode.

2.) As Jisha suggested in one of the previous posts, I could manipulate the size of combo box button by altering GridComboBoxCellModel . But since, the row is autosized, the drop down of the combo box still appears below the row. Is there a way I can control it to appear right below the combo box button?

3.) I have a Pushbutton celltype. How do I control the size of the button? I tried the same approach as above by altering the buttonbar size of the GridPushButtonCellModel . Doesn't seem to work.

I would really appreciate any suggestions.

Thank you.

Vidya



JJ Jisha Joy Syncfusion Team September 18, 2009 10:41 AM UTC

Hi Vidya,

1. Please refer the sample that implement this:
http://websamples.syncfusion.com/samples/Grid.Windows/Grid_WF_NoScrollBars.zip
2. This can be achieved by deriving the GridComboBoxCellModel and GridComboBoxCellRenderer. See the sample:
http://files.syncfusion.com/support/Grid.Windows/89945.zip

3. You can change the size of the Cell Button using DrawCellButton Event. Here is the code snippet.

private void gridControl1_DrawCellButton(object sender, Syncfusion.Windows.Forms.Grid.GridDrawCellButtonEventArgs e)
{
if(e.ColIndex == 4 && e.RowIndex == 4)
e.Button.Bounds = new Rectangle(new Point(e.Button.Bounds.X + (int)e.Button.Bounds.Width /2 ,e.Button.Bounds.Y),new Size((int)e.Button.Bounds.Width/2 ,e.Button.Bounds.Height ));
}



Regards,
Jisha


VN Vidya Nara September 21, 2009 03:46 PM UTC

Hi,

Regarding the above problem of hyperlinks, I am trying the alternative solution of having a hyperlink column.


Can you please suggest how can I have multiple hyperlinks on a cell pointing to different URLs?


Ex: Contents of the same cell:

-------
Google(Pointing to http://www.google.com)
Yahoo(Pointing to http://www.yahoo.com)
-------

An example will be of great help.

Thank you.

regards,
Vidya


JJ Jisha Joy Syncfusion Team September 22, 2009 05:08 AM UTC

Hi vidya,

Please refer the following sample that implements multiple links in a cell
Sample link

In this sample hyperlinks are drawn using TableControlDrawCell event. The cell is splitted into multiple layouts based on the number of hyperlinks to be displayed and events handled based on the rect accordingly. The mousecursor is handled through the TableControlCellCursor event and TableControlCellMouseUp event is handled to launch the appropriate links based on the text on which cellclick is made. If you would like to add further hyperlinks, you have to split the cell rectangle accordingly.

Regards,
Jisha


VN Vidya Nara October 1, 2009 09:20 PM UTC

Hi Jisha,

I have another question:

I have a column in a gridgroupingcontrol which is of "Pushbutton" cell type. I was able to set the size of the button by setting the e.Inner.Button.Bounds. How do I set the background image for the button (Just for the button, not the entire cell).

I have to handle it in the TableControlDrawCellButton event handler.

My partial code:


void m_GridControl_TableControlDrawCellButton(object sender, GridTableControlDrawCellButtonEventArgs e)
{
if (e.Inner.ColIndex == 3)
{
e.Inner.Button.Bounds = new Rectangle(new Point(e.Inner.Button.Bounds.X, e.Inner.Button.Bounds.Y), new Size(48, 18));

}


}


Thank you.

regards,
Vidya


LS Lingaraj S Syncfusion Team October 2, 2009 11:46 AM UTC

Hi Vidya,

Thank you for the update.

PushButton cell type is not allowing to insert a background image in button. If you want a background image in cell button, then please try using CustomButtonEdit cell type in cells to achieve your requirement.

Please refer the shipped sample from the below location:
“..\Documents\syncfusion\essentialstudio\{installed version}\Windows\Grid.Grouping.Windows\Samples\2.0\Product Showcase\Cut-Copy-Paste Demo\cs

Please let me know if you have any queries.

Regards,
Lingaraj S.


VN Vidya Nara October 2, 2009 05:48 PM UTC

Hi Lingaraj,

The reference example that you provided me with does not contain any CustomButtonEdit cell defined. Can you please point me to the right one?

Thanks,
Vidya


LS Lingaraj S Syncfusion Team October 5, 2009 09:41 AM UTC

Hi Vidya,

Sorry for the inconvenience caused.

Please refer the shipped sample from the below location:
“..\Documents\syncfusion\essentialstudio\{installed version}\Windows\Grid.Windows\Samples\2.0\Custom Cell Type\Button Edit Cell Demo\cs

Please let me know if you have any queries.

Regards,
Lingaraj S.

Loader.
Live Chat Icon For mobile
Up arrow icon