Assignment Problem - c#

my problem is that for some reason, a simple assignment isn't working.
the dataGridView is binded to DB and im trying to assign a value type string to a column of type string
enter code here //the initialization of the DataGridView
bindingSourceSchema.DataSource = null;
dgwSchema.Columns["colID"].DataPropertyName = "APP_ID";
dgwSchema.Columns["colName"].DataPropertyName = "DESCRIPTION";
dgwSchema.Columns["colTextbox"].DataPropertyName = "APP_ARGS";
dgwSchema.Columns["colTextbox"].HeaderText = "Parameters";
dgwSchema.Columns["colLink"].DataPropertyName = "APP_PATH";
dgwSchema.Columns["colLink"].HeaderText = "Path";
DataGridViewLinkColumn colLink = (DataGridViewLinkColumn)dgwSchema.Columns["colLink"];
colLink.UseColumnTextForLinkValue = true;
colLink.Text = "Edit";
bindingSourceSchema.DataSource = SchemaDB.GetGenericApps();//the assignment
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
dgwSchema.CurrentRow.Cells["colLink"].Value = openFileDialog.FileName;
// !! ?? dgwSchema.CurrentRow.Cells["colLink"].Value STAYS with parameter "Edit"
}
Thanks
Eyal

It could be a problem with where you are running this code. Is this in the PageLoad event? Make sure the grid is not being bound again after you do this. What does the debugger show you if you put a break point after the assignment?

The reason is following property is set to true.
colLink.UseColumnTextForLinkValue = true;
Set it to false. Then it will resolve your problem.

Related

How to set page layout break on worksheet using EPPlus

Is there a way to set specify where to break the page using EEPlus? I have the following code that sets the printer properties but haven't found a way to set a break point on a certain column.
// Set printer settings
ws.PrinterSettings.PaperSize = ePaperSize.Tabloid;
ws.PrinterSettings.Orientation = eOrientation.Landscape;
ws.PrinterSettings.FitToPage = true;
ws.PrinterSettings.FitToHeight = 1;
ws.PrinterSettings.FooterMargin = .05M;
ws.PrinterSettings.TopMargin = .05M;
ws.PrinterSettings.LeftMargin = .05M;
ws.PrinterSettings.RightMargin = .05M;
Edit (this helped solve my problem)
ws.Column(30).PageBreak = true;
ws.PrinterSettings.PaperSize = ePaperSize.A3;
ws.PrinterSettings.Orientation = eOrientation.Landscape;
ws.PrinterSettings.Scale = 75;
Just need to get reference to the Row and/or Column objects:
ws.Row(20).PageBreak = true;
ws.Column(2).PageBreak = true;
But keep in mind that FitToPage might suppress these.

DevExpress: How to set programmatically diagram to chart control

I create ChartControl dynamiclly and I have to set Diagram property as dynamiclly.
Here is my code:
XYDiagram xyDiagram1 = new XYDiagram();
xyDiagram1.AxisX.Title.Text = "";
xyDiagram1.AxisX.VisibleInPanesSerializable = "-1";
xyDiagram1.AxisX.WholeRange.Auto = false;
xyDiagram1.AxisX.WholeRange.AutoSideMargins = false;
xyDiagram1.AxisX.WholeRange.MaxValueSerializable = "10";
xyDiagram1.AxisX.WholeRange.MinValueSerializable = "5";
xyDiagram1.AxisX.WholeRange.SideMarginsValue = 2.5D;
xyDiagram1.AxisY.Title.Text = "";
xyDiagram1.AxisY.VisibleInPanesSerializable = "-1";
barChart.Diagram = xyDiagram1;
But it throws This property can't be customized at runtime. exception. Do you have any suggestion?
An instance of ChartControl.Diagram is automatically created by a chart. The ViewType enumerable controls what diagram is created. So, cast the ChartControl.Diagram property to your diagram type to get it. You don't need to create a diagram manually.

Can't display linklabel text in a datagridviewlinkcolumn

I have a little but pretty annoying problem:
I have created a datagridview and bound it to a datasource.
Then now I want to add a column which will display links for the user to click.
In order to do that i added a datagridviewlinkcolumn. For each rows of the datagrid I set the value of the cell in that column to the text i want to be displayed. But it shows nothing. All the datagridlinkcolumn is filled with "blank text".
Here is my code:
DataGridViewLinkColumn dgvColDeletion = new DataGridViewLinkColumn();
dgvColDeletion.Name = "Deletion";
dgvColDeletion.HeaderText = "";
dgvColDeletion.ReadOnly = false;
dgvTrainings.Columns.Add(dgvColDeletion);
foreach (DataGridViewRow row in dgvTrainings.Rows)
{
row.Cells["Deletion"].Value = "Delete";
}
dgvColDeletion.Update();
dgvTrainings.Update();
I also tried with setting directly linklabels or datagridviwlinkcells, but the problem still remains.
I cant get any clue why this isn't working.
Any help will be very much appreciated, thanks.
To display the same link text for every cell, set the UseColumnTextForLinkValue property to true and set the Text property to the desired link text.
DataGridViewLinkColumn dgvColDeletion = new DataGridViewLinkColumn();
dgvColDeletion.UseColumnTextForLinkValue = true;
dgvColDeletion.Text = "Delete";
Try this. I hope this will helps to you.
DataGridViewLinkColumn dgvColDeletion = new DataGridViewLinkColumn();
dgvColDeletion.UseColumnTextForLinkValue = true;<br/>
dgvColDeletion.Text = "Delete";<br/>
dgvColDeletion.ActiveLinkColor = Color.White;<br/>
dgvColDeletion.LinkBehavior = LinkBehavior.SystemDefault;<br/>
dgvColDeletion.LinkColor = Color.Blue;<br/>
dgvColDeletion.TrackVisitedState = true;<br/>
dgvColDeletion.VisitedLinkColor = Color.YellowGreen;<br/>
dgvColDeletion.Name = "Delete";<br/>
dgvColDeletion.HeaderText = "Delete";<br/>
if (grid_shared.Columns.Contains("Delete") == false)<br/>
{<br/>
dgvColDeletion.Columns.Add(lnkDelete);<br/>
dgvColDeletion.Columns["Delete"].Width = 40;<br/>
}<br/>
Happy coding..:)

AspxGridView selection at runtime

I have an aspxGridView on my page, and i create the columns at runtime. I also add CommandColumn with ShowSelectCheckBox set to true. But after i select one row and click a button to get the row values, AspxGridView.Selection.Count returns 0. I create this GridView on AspxButtons Click event also for paging, create the gridView on Page_Init. Here is the code to create the AspxGridView:
Colenter code hereorCollection colorCol = ConfAttributesManager.Instance
.GetColors();
if (colorCol.Count > 0)
{
GridViewDataTextColumn grdColorCodeColumn = new GridViewDataTextColumn();
grdColorCodeColumn.FieldName = "ColorCode";
GridViewDataTextColumn grdDescriptionColumn = new GridViewDataTextColumn();
grdDescriptionColumn.FieldName = "Description";
gv_Attributes.Columns.Clear();
gv_Attributes.Columns.Add(grdColorCodeColumn);
gv_Attributes.Columns.Add(grdDescriptionColumn);
GridViewCommandColumn grdCmdColumn = new GridViewCommandColumn();
grdCmdColumn.ShowSelectCheckbox = true;
grdCmdColumn.VisibleIndex = 0;
gv_Attributes.Columns.Add(grdCmdColumn);
gv_Attributes.DataSource = colorCol;
gv_Attributes.DataBind();
}
I don't know where do i make a mistake?
Thanks for your help.
It seems that you do not specify the ASPxGridView.KeyFieldName property that is required for Row Selection operation:
gv_Attributes.KeyFieldName = "ColorCode";
//gv_Attributes.KeyFieldName = Unique Key Field;

set value in BaseFieldControl or RichTextField

I want programmatical set value in my own field type. So I override method FieldRenderingControl (this is call when click into element in sharepoint list).
my code:
public override Microsoft.SharePoint.WebControls.BaseFieldControl FieldRenderingControl
{
get
{
BaseFieldControl fakeFieldControl = base.FieldRenderingControl;
RichTextField rtf = new RichTextField();
rtf.ID = "MultilineRichText";
rtf.ListId = fakeFieldControl.ListId;// list.ID;
rtf.ItemId = fakeFieldControl.ItemId;// item.ID;
rtf.FieldName = "MultilineRichText";
rtf.ControlMode = SPControlMode.Display;
rtf.Text = "test rich text";
rtf.Value = "test rich text value";
rtf.ItemFieldValue = "item field value";
rtf.ListItemFieldValue = "list item field value";
return rtf;
the result: contol mode is always in display mode, that work fine. But the column value is always empty.
Any help? I do not have any idea!
If I remember correctly, you have to set the value BEFORE setting the ControlMode = SPControlMode.Display.
Edit: I just saw that's an old post... hope you had find an answer :)

Categories