C# LocalReport change textbox location - c#

How can I change position in LocalReport of any object. Like TextBox or Image and so on. For example try to change Left coordinate.
I was try this way:
ReportParameterCollection reportParameters = new ReportParameterCollection();
reportParameters.Add(new ReportParameter("ReportParameter1", "ValueFromCode"));
report.SetParameters(reportParameters);
but i can't establish a link between reportParameters and location of element.

You can use expressions to dynamically assign values to properties. For instance, if you open a TextBox properties, go to Alignment, and then click on Fx - located to the right of the Left padding field for instance - the expression editor will open.
There, you can select some report parameter like the ReportParameter1 from your example. This would be translated into the following .rdlc code inside the Style tag of the corresponding TextBox:
<PaddingLeft>=Parameters!ReportParameter1.Value</PaddingLeft>
Your ValueFromCode may be something like 10pt, or some numeric value instead, to which you may then append the units, for instance:
<PaddingLeft>=Parameters!ReportParameter1.Value & "pt"</PaddingLeft>
Now, this example is for padding, which you can edit using the designed. I haven't tried it, but in order to set the location dynamically you may be able to do the same for the Top and Left properties of the TextBox (or the desired element), by manually editing the .rdlc file. Give it a try.

Related

C#: How can I programmatically loop through all controls on a Windows Form

I'm in the process of creating a front-end Windows Forms application, which will have multiple uses. One of those uses will be to allow the end-user to manage the contents of a database table.
At the moment, my form contains a DataGridView object which uses a DataTable as its source. That datatable is populated from a stored procedure which selects every row from the table based on criteria specified by the end user. I want to put code into the DataGridView which will look at the row that's been selected by the user, and will populate a series of text boxes with the details from that row.
I want to avoid hard-coding a text box for each column in the DataGridView, since it's highly possible that in the future I might add columns to the underlying stored procedure. Therefore, my plan is that the first time the user selects a row, the application would dynamically create a text box for each column, size that text box appropriately (both height and width) and add the appropriate labels.
So far, the code I've written creates a brand-new DataTable, and adds columns to store the following information about each column in the DataGridView:
The actual name of the DataGridView column;
The name that I wish to give to the associated label;
The text that I wish to assign to the associated label;
The top and left positions of the associated label;
The name that I wish to give to the associated text box;
The value that I wish to display in the associated text box;
So far when the user initially clicks on a row, everything is working well: the text boxes get created in a vertical column, with the associated label to the left of each text box and the appropriate value displayed in each one. Each text box has its width dynamically set based on the contents of that text box so that everything can easily be seen.
The difficulty comes when the user changes from one row of the DataGridView to another. The code that runs to create each control looks like this:
if (pnlManageJobManagerOutcomes.Controls.Contains(txtCurrent))
{
pnlManageJobManagerOutcomes.Controls.Remove(txtCurrent);
}
if (!pnlManageJobManagerOutcomes.Controls.Contains(txtCurrent))
{
pnlManageJobManagerOutcomes.Controls.Add(txtCurrent);
}
When the code first runs, all seems to be fine. However, if it gets fired a second time (at which point it should remove and re-create the control) it doesn't seem to detect the prior existence of the control and simply creates a second copy of it in the form.
For information, the form I'm building has multiple uses which are dictated by a series of buttons. Therefore, I'm creating the controls for this particular use inside a Panel (pnlManageJobManagerOutcomes). I'm completely stumped as to why the code doesn't spot the existence of those controls during subsequent executions.
TIA
I've figured out a way to do it, which may seem to be clunky but which seems to work.
Since it doesn't appear that I can check to see whether the Panel I'm working with Contains the field name, I've written a method which will loop through the controls in that Panel and return a count of the number of instances of that control in the Panel's Controls array. If the method returns a 0, this means the Control doesn't exist in that Panel and I can go ahead and create it.

How can you fill a table cell using Selenium?

I'm trying to fill a table using the selenium drivers and all the documentations I could find only shows how to retrieve data from the cells. I'm able to access my table cells using:
var rows = Driver.FindElement(By.Id("Products")).FindElements(By.XPath("id('Products')/tbody/tr"));
var cells = tableRows[1].FindElements(By.XPath("td"));
But I couldn't find any way to update the data that's in it. The "Text" property only has a Get method and the SendKeys() function doesn't work. How can I edit the cell's value?
As a side note, my cell contains an html "input", I've tried to access it with the FindElement function of the cell but for some reasons it cannot find it.
Generally speaking, SendKeys should work if the cell indeed contains the input element. But because you're also saying that you fail to find the input element, I suspect that the input element does not exist in each cell all the time. You should probably first click on the cell in order for the input element to appear on that cell. You should be able to verify it using the Dev Tools if you inspect the element before clicking it.
IWebElement doesn't provide a method to change text, but you could use a little bit of JS - something little like :
((IJavaScriptExecutor)Driver).ExecuteScript("document.getElementByXXXXX.innerHTML = "VALUE";");
https://seleniumhq.github.io/selenium/docs/api/dotnet/html/M_OpenQA_Selenium_IJavaScriptExecutor_ExecuteScript.htm

Revit API - prompt user to create vertical column

I am writing a plugin for Revit 2014. One of its features placing a vertical column by the user. Revit API allows placing family instances by the user with the method PromptForFamilyInstancePlacement, which is what I'm using, like so:
//PillarSymbols is a list containing symbols of various columns available, loaded previously from a file
FamilySymbol symbol = PillarsSymbols.Single(x => x.Kind == selected.Kind).Symbol;
_commandData.Application.ActiveUIDocument.PromptForFamilyInstancePlacement(symbol);
This code enables Modify | Place structural column tool in Revit application. It works as desired, but does not allow the user to switch between Vertical Column and Slanted Column. This option is set to whatever it was set before running the code above.
I have tried to set the symbol parameters before running PromptForFamilyInstancePlacement using:
symbol.get_Parameter(BuiltInParameter.SLANTED_COLUMN_TYPE_PARAM).Set(value);
but get_Parameter() above returns null.
Is there a method to set column type to Vertical Column, before prompting the user to place the column? Also is there a way to pre-set column height?
Unfortunately you can't preset the column height but you can adjust the free end of the item created directly afterwards. You should be returning a FamilyInstance, so if you grab it again then you can adjust the free end of it.
You may be able to prompt the user to place the correct symbol by cycling through the symbols in the family. Try the snippet below and check to make sure that the symbol produced is the one that you want before placement:
FamilySymbol familySymbol = family.Symbols.ForwardIterator().Current as FamilySymbol;

.NET Charting Controls: Label values from data source

I know that you can use keywords with labels, but is there any way to use a specific value from my data set as a label? What I would like to do is have a column of my data table contain a custom label string, so that each X-axis value graphed would have a unique label, but it seems there is no way to connect a series to an element from my data source. Is there a workaround to this, or will I just have to manually add labels over the chart?
I believe you are looking for setting a label for your datasource which is different from the columns which derive the X and Y values.In that case you can do this in the following manner
Chart1.Series[0].Points.DataBind(data, "XValue", "YValue",
"ToolTip=mytooltip,Label=LabelColumnName");
Here you can specify the column name against Label which would be used to display the label, in the same fashion you could also set up the tooltip from a different property.
If this is not you are looking out then please update the question with more details.
EDIT
you can set the position of the label using CustomProperties of the series
Chart1.Series[0].CustomProperties = "LabelStyle=Left"; Check this

Ms-Chart Label Format Question

I created a PieChart with the new Ms Chart Controls. How can I format the Labels (Point Values inside the Pie) like the folllowing: "LabelName AbsoluteValue (Percentage)"? For example: "Usa 856027 (56 %)".
Is this possible with the right format information in LabelFormat alone (How?) or do I have to use a custom label format (How?) ?
Thank you very much!
Rupert Rand
You can include keywords in the Label property, which can either be set in the GUI(through the Series Collection Editor) or in code. I would recommend setting it through the GUI since it would not require a full knowledge of the available keywords. If you instead want to set it in the code, it would look similar to this (assuming I understand what format you are requesting): Chart.Series(0).Label = "#ValX #Val (#ValPercentY{P0})".

Categories

Resources