Dear all,
How to make part of the text in the cells to be URL or HyperLink?? so that it will trigger the function with the URL Value??
e.g. Trans. No: 1234567890
Before I am using below with the whole cell.
private void dtgSalesTransactionsList_AfterCellActivate(object sender, EventArgs e)
Assuming the data type of the column to be typeof(object): set the column's Style property to 'URL', then assign a value like this to the cell:
cell.Value = new Infragistics.Win.FormattedLinkLabel.ParsedFormattedTextValue( "<a href = \"http://www.whatever.com\">1234567890</a>");
You could also use a String column and set the Style to FormattedText. Then you set the Value of the cell to any string which uses our custom XML Format, just like the UltraFormattedLinkLabel control.
So you could put text and a link in the cell together by using a cell value like this:
"Trans. No: <a href = \"http://www.whatever.com\">1234567890</a>"
If you want to trap clicks on this link instead of just letting the O/S launch the URL, then you would have to use a FormattedLinkLabel control as the EditorComponent of the cell/column. In this case, you do not need to set the Style, and you can trap the LinkClicked event of the FormattedLinkLabel.
Instead of setting he column Style, you need to place an UltraFormattedTextEditor or UltraFormattedLinkLablel on the form and attach it to the grid column using the EditorComponent property of the column.
You will probably want to use the label, since I imagine your cell will be read-only.
Anyway, you define the links the same say, but you can put any text you want in for the URL. Then you handle the LinkClicked event of the UltraFormattedLinkLablel. This event will fire when the user clicks a link in any cell and the event args will give you information about the link (including the URL you used) and then you can launch a form or do whatever you want.
Could you describe the steps or any sample code??
(1) place an UltraFormattedLinkLabel on the form
(2) attach it to the grid column using the EditorComponent property of the column.
(3) put the text "Trans No: 123456" you want in for the URL
(4) Any sample code in LinkClicked event of the UltraFormattedLinkLabel
Hi,
There isn't much to it. I've attached a sample here with a simple grid on a form bound to an UltraDataSource with a single string column.The code looks like this:
private void Form1_Load(object sender, EventArgs e) { this.ultraDataSource1.Rows.Add(new object[] { "Trans. No: <a href = \"100\">100</a>" }); this.ultraDataSource1.Rows.Add(new object[] { "Trans. No: <a href = \"200\">200</a>" }); this.ultraDataSource1.Rows.Add(new object[] { "Trans. No: <a href = \"300\">300</a>" }); this.ultraDataSource1.Rows.Add(new object[] { "Trans. No: <a href = \"400\">400</a>" }); } private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { UltraGridLayout layout = e.Layout; UltraGridBand rootBand = layout.Bands[0]; rootBand.Columns["Column 0"].EditorComponent = this.ultraFormattedLinkLabel1; } private void ultraFormattedLinkLabel1_LinkClicked(object sender, Infragistics.Win.FormattedLinkLabel.LinkClickedEventArgs e) { Infragistics.Win.UltraMessageBox.UltraMessageBoxManager.Show(this, e.LinkRef, "Link Clicked"); }
Howdy, I'm new to infragistics and .Net, bad start. I'm trying to do this with a column of data bound to a database source. When I use the ultraformattedlinklabel on the ultragrid form, it hides everything in the form. I've set it up as an editor component, and have had no success. So, to clarify:I've created a the above methods, specified to the column I'm working with. And have added the UltraformattedLinkLabel on the form. I will eventually want to filter which row values get initialized as links, but for now just getting the data to show up while utilizing the UltraFormattedLinklLabel would be grand. Hope you can help, this is the only place I've found an example close to what I would like to do!
Hi Tomegen,
I'm having some trouble understanding you. What do you mean by "it hides everything in the form"?
Are you saying that all of the controls on the form disappear? I can't imagine any way that the UltraFormattedTextEditor could cause that. Sounds like maybe your project has mixed references or has become corrupted somehow.
So let me see if I understand this...
You have a column in the grid with a ValueList with three options. And when the user selects one of those options (Cancelled), you want to cell to display as a link. Is that right?
If so, then there's no simply way to do this. If the cell has a dropdown list in it, then it has to use an editor that supports dropdown lists (typically EditorWithCombo). If you replace the cell's editor with a FormattedLinkLabel or FormattedTextEditor, then you will gain the ability to show hyperlinks, but you will lose the ability to show the dropdown list.
The only way to achieve this would be to create a FormattedTextEditor control and use an EditorButton in the ButtonsRight collection with a dropdown control on it that provides the list. But then you would have to re-implement all of the normal dropdown list functionality like choosing an item from the list updating the control and also finding the selected item on the list when it drops down.
Sorry, I wasn't clear enough. The code is a bit confusing for me to understand as well. I'll describe the column first,
Style: DropDownListValueList: Status // The status is a string descriptor, based on the enumerated decimal value
// So, this is where the value list used in the grid is populated. ValueList list = dgStat.DisplayLayout.ValueLists["NStatus"]; foreach ( NStatus status in System.Enum.GetValues(typeof( NStatus))) list.ValueListItems.Add((decimal)(int)status, status.ToString("F"));
// And the enumeration looks something like this:public enum NStatus{ [Description("Open")] Open = 0, [Description("Closed")] Closed = 1, [Description("Canceled")] Canceled = 2,}
The descriptions are the strings that display on the ultraGrid, and also the lines that I would like to hyperlink when canceled is the option. But, when I try to get it to link, with the above mentioned solution, all of the information on the grid, save the headers, disappear.Normal:A B C D1 2 3 42 3 4 55 6 3 7Then loses all data when the EditorComponent is set to the UltraFormattedLinkLabel the only thing that shows is:A B C DMy phrasing might be a bit off, but is this making more sense?
Hi Dan,
I seem to be getting more and more confused. If the column is of type Decimal that might cause a problem. The FormattedLinkLabel expects a string. I would think it would work, because a decimal (or pretty much anything) can be converted to a string. But you'd never be able to show a link using decimal data, since it cannot possibly contain the XML necessary to define a hyperlink.
I'm also baffled by what you mean when you say the "dataset is an enumeration." Unless you are using the word enumeration is some way I don't understand, this doesn't make sense to me. An enumeration is a data type, a data set can't be one.
At this point, I'm not even clear on exactly what you are trying to achieve. Maybe you could post a small sample project here or some screen shots of what you want to achieve?
Greetings Mike,
The column is of type System.Decimal and in this case all of the columns do not show when I set the EditorComponent to UltraFormattedLinkLabel, or if I change the style of the column to URL. As mentioned before, it is bound to a dataset, which is an enumeration. The enumeration has a string of the word that I would like to convert to an URL. And, I see how that could be a problem, I'm just not sure of how. We've tried converting the text component to a URL, with the InitializeRow method, but it had no effect. None of the text changes, and hence we cannot envoke an onLinkClicked style method.
Hope this helps and thanks,
Dan
So which columns aren't showing any data? All of them? Or just the column with the UltraFormattedLinkLabel attached. I'm confused because you say you are attaching the UltraFormattedLinkLabel to a single column, but then you say that "columns" (plural) are not showing any data.
What's the data type of the column that you are attaching the UltraFormattedLinkLabel to?
Does the column contain strings that are hyperlinks?
Can you post a small sample project demonstrating the issue? That would probably save a lot of time.