I have a problem getting the tabPage->Name value, because it will generate when user click the button, first block of my code will create new tabsheet inside PageControl3 and then I use the static int tabNumber; by if condition to generate the tabPage->Caption and then I use the caption for tabPage->Name dynamically.
I need the name of that tabsheet to pass it on the Error line.
static int tabNumber;
if (tabNumber >= 1) ++tabNumber;
else tabNumber = 1;
PageControl3->Visible = true;
TTabSheet *tabPage = new TTabSheet(PageControl3);
tabPage->PageControl = PageControl3;
tabPage->Caption = UnicodeString("Untitled") + IntToStr(tabNumber);
tabPage->Name = UnicodeString("ts") + tabPage->Caption;
The second part of my code should create new TPanel inside current tabpage->Name that was created in the above part of my code, BUT it wont work.
TPanel *panelPage = new TPanel(tabPage->Name); // Error Line
panelPage->Align = alClient;
panelPage->Name = UnicodeString("panel") + tabPage->Caption;
Error massage:
[bcc32 Error] mainUnit.cpp(50): E2285 Could not find a match for 'TPanel::TPanel(const UnicodeString)'
So I not know how to access the tabPage->Name value, because that was create dynamically?
DB Baxter The constructor requires a component variable/object and not a string with the text of the name. Such as TPanel *panelPage = new TPanel(tabPage); Will that work for you? Do you need to make the panel's parent tabPage?
By helping DB Baxter, I think the correct and complete answer for create dynamic TPanel inside the dynamic TTabSheet will requires a component variable/object and then for displaying the TPanel we should use the whatever->show(); command, the full code can bee like this:
static int tabNumber = 0;
if (tabNumber >= 1) {
++tabNumber;
} else {
tabNumber = 1;
PageControl3->Visible = true;
}
// create new tab sheet inside PageControl3
TTabSheet *tabSheet = new TTabSheet(PageControl3);
tabSheet->PageControl = PageControl3;
tabSheet->Caption = UnicodeString("Untitled") + IntToStr(tabNumber);
tabSheet->Name = UnicodeString("ts") + tabSheet->Caption;
// create new panel inside the current tab sheet
TPanel *panelBox = new TPanel(tabSheet);
panelBox->Parent = tabSheet;
panelBox->Align = alClient;
panelBox->Name = UnicodeString("panelPage") + IntToStr(tabNumber);
panelBox->BevelOuter = bvNone;
panelBox->ShowCaption = true;
panelBox->Caption = UnicodeString("panel") + tabSheet->Caption;
panelBox->Show();
I hope this code can help anyone to generate the dynamic tab sheet with panel, by the way if you want add some frame to it the following code should use:
// adding the registration frame to the panel
TregFrame *newRegistration = new TregFrame(panelBox);
newRegistration->Parent = panelBox;
newRegistration->Align = alClient;
Note: don't forget to include your frame in your working file, for example #include "registrationFrame.h".
Related
How does one Call the Onclick event for cxGrid Navigator buttons? I can't seem to find it.
Screenshot below...
Thanks,
In the following example View is the TcxGridDBTableView owning the Navigator:
The Navigator Buttons are exposed via a property on View called NavigatorButtons. NavigatorButtons is of type TcxNavigatorControlButtons
On TcxNavigatorControlButtons you'll find all you buttons:
TcxNavigatorControlButtons = class(TcxCustomNavigatorButtons)
...
published
property ConfirmDelete;
property CustomButtons;
property Images;
property First;
property PriorPage;
property Prior;
property Next;
property NextPage;
property Last;
property Insert;
property Append;
property Delete;
property Edit;
property Post;
property Cancel;
property Refresh;
property SaveBookmark;
property GotoBookmark;
property Filter;
end;
So if you want to click on the "Next" button you could write
View.NavigatorButtons.Next.Click;
IF and only IF the button is enabled then the OnClick event will fire.
There are 16 buttons, each one defined byt it's own index:
const
NavigatorButtonCount = 16;
NBDI_FIRST = 0;
NBDI_PRIORPAGE = 1;
NBDI_PRIOR = 2;
NBDI_NEXT = 3;
NBDI_NEXTPAGE = 4;
NBDI_LAST = 5;
NBDI_INSERT = 6;
NBDI_APPEND = 7;
NBDI_DELETE = 8;
NBDI_EDIT = 9;
NBDI_POST = 10;
NBDI_CANCEL = 11;
NBDI_REFRESH = 12;
NBDI_SAVEBOOKMARK = 13;
NBDI_GOTOBOOKMARK = 14;
NBDI_FILTER = 15;
If you prefer you can ude this index to click a certain button:
View.NavigatorButtons.ClickButton(NBDI_EDIT);
Hope this answers your question.
I am using ReportViewer 11 to display a report inside an iframe (aspx page is loaded into iframe). It displays first page properly. But when I click on next page, it loads the first page again. Even if I type in page number manually into the textbox, it loads first page only. It seems like, it doesn't fire the pagenavigation event in the server side. If I set the currentpage property to 2 in code behind, then also it loads page 1 only no matter what settings I provide.
Searched for this for days. Got no solution.
Any help will be appreciated.
Thanks
Apply this logic
Store the records in container1
Pass the records to container2
print 5 records(or may be more) from container2
when "next" button is pressed print next 5 from container2
and so on.
I dont know whether this will help you, but records from database can be paginated in this way.
I have tried this logic too. But the main problem is that ReportViewer.CurrentPage is 0 always (in my case) even when the "next" button is pressed. So it will again show the container1 records. This is my code:
public void SetReportData(ref ReportViewer objRptVwr, ReportParameter[] rptParam, string moduleName, string reportName, string dsName, System.Data.DataTable dtFinal){
objRptVwr.Reset();
objRptVwr.ProcessingMode = ProcessingMode.Local;
objRptVwr.LocalReport.ReportPath = HttpContext.Current.Server.MapPath("~/ReportViewer/" + moduleName + "/" + reportName + ".rdlc");
if (rptParam != null)
objRptVwr.LocalReport.SetParameters(rptParam);
objRptVwr.ShowPrintButton = true;
objRptVwr.ShowParameterPrompts = true;
objRptVwr.AsyncRendering = false;
objRptVwr.InteractivityPostBackMode = InteractivityPostBackMode.AlwaysSynchronous;
objRptVwr.ShowBackButton = true;
objRptVwr.SizeToReportContent = false;
objRptVwr.PageCountMode = PageCountMode.Actual;
objRptVwr.ShowExportControls = true;
objRptVwr.ShowPageNavigationControls = true;
objRptVwr.ShowToolBar = true;
objRptVwr.ShowWaitControlCancelLink = false;
objRptVwr.ShowZoomControl = true;
objRptVwr.LocalReport.EnableExternalImages = true;
objRptVwr.ExportContentDisposition = ContentDisposition.AlwaysInline;
ReportDataSource reportDataSource = new ReportDataSource(dsName, (System.Data.DataTable)dtFinal);
objRptVwr.LocalReport.DataSources.Clear();
objRptVwr.LocalReport.DataSources.Add(reportDataSource);
objRptVwr.LocalReport.Refresh();
}
What I did that the generated buttons will be according to the list size.
Each buttons(may be li tag) will have a textfield containing value like 0,5,10 and so on dynamically(In case of 5 elements per page).
A button is clicked, the value of that textfield(e.g index) I got and shifted the resulset position to index and print the records upto 5 elements.
I am using Embarcadero RAD Studio XE7, C++ Builder with FastReport 5. I create a very simple FastReport that adds up some values in a table and prints out a total. I cannot get the syntax for the sum formula correct, and as a result it keeps throwing an access violation error.
To reproduce this problem in RAD Studio XE7:
Open RAD Studio XE7 and go to File -> New -> VCL Forms Application - C++Builder
Drag a TClientDataSet component named ClientDataSet1 onto the form. Drag a TfrxReport component named frxReport1 onto the form. Drag a TfrxDBDataset named frxDBDataset1 onto the form.
Drag a TButton named Button1 onto the form, and double-click it to create an OnClick event handler.
Add the following lines to the Button1Click event handler:
// Create a simple dataset.
ClientDataSet1->FieldDefs->Clear();
ClientDataSet1->FieldDefs->Add("ID", ftInteger, 0, false);
ClientDataSet1->FieldDefs->Add("Status", ftString, 10, false);
ClientDataSet1->FieldDefs->Add("Created", ftDate, 0, false);
ClientDataSet1->FieldDefs->Add("Volume", ftInteger, 0, false);
try
{
ClientDataSet1->CreateDataSet();
}
catch(Exception& e)
{
ShowMessage("ERROR: '" + e.Message + "'");
return;
}
ClientDataSet1->Open();
for (int i = 0; i < 10; ++i)
{
ClientDataSet1->Append();
ClientDataSet1->FieldByName("ID")->AsInteger = i;
ClientDataSet1->FieldByName("Status")->AsString = "Code" + String(i);
ClientDataSet1->FieldByName("Created")->AsDateTime = Now();
ClientDataSet1->FieldByName("Volume")->AsInteger = Random(1000);
try
{
ClientDataSet1->Post();
}
catch(Exception& e)
{
ShowMessage("ERROR: '" + e.Message + "'");
ClientDataSet1->Close();
return;
}
}
// Dataset created successfully, now create Fast Report that outputs that dataset
frxReport1->Clear();
frxDBDataset1->DataSet = (TDataSet*)ClientDataSet1;
frxReport1->DataSets->Add(frxDBDataset1);
TfrxDataPage* DataPage = new TfrxDataPage(frxReport1);
DataPage->CreateUniqueName();
TfrxReportPage* Page = new TfrxReportPage(frxReport1);
Page->CreateUniqueName();
// set sizes of fields, paper and orientation to defaults
Page->SetDefaults();
Page->Orientation = poPortrait;
TfrxReportTitle* HeaderBand = new TfrxReportTitle(Page);
HeaderBand->CreateUniqueName();
HeaderBand->Top = 0;
HeaderBand->Height = 20;
TfrxMemoView* Memo = new TfrxMemoView(HeaderBand);
Memo->CreateUniqueName();
Memo->Text = "Generic Report";
Memo->SetBounds(0, 0, 200, 20);
TfrxHeader* ColumnHeaderBand;
ColumnHeaderBand = new TfrxHeader(Page);
ColumnHeaderBand->CreateUniqueName();
ColumnHeaderBand->Top = HeaderBand->Top + HeaderBand->Height;
ColumnHeaderBand->Height = 20;
TfrxMasterData* DataBand = new TfrxMasterData(Page);
DataBand->Name = "DataBand";
DataBand->DataSet = frxDBDataset1;
DataBand->Top = ColumnHeaderBand->Top + ColumnHeaderBand->Height;
DataBand->Height = 20;
TfrxMemoView* mField;
for (int i = 0; i < DataBand->DataSet->FieldsCount(); ++i)
{
const String fieldname = ClientDataSet1->Fields->Fields[i]->FieldName;
mField = new TfrxMemoView(ColumnHeaderBand);
mField->CreateUniqueName();
mField->SetBounds(i * 100, 0, 100, 20);
mField->Text = fieldname;
mField->HAlign = haCenter;
// Now do the actual data
mField = new TfrxMemoView(DataBand);
mField->CreateUniqueName();
mField->DataSet = DataBand->DataSet;
mField->DataField = fieldname;
mField->SetBounds(i * 100, 0, 100, 20);
mField->HAlign = haRight;
}
// Now do footer band. This will hold the total
TfrxBand* FooterBand = new TfrxFooter(Page);
FooterBand->CreateUniqueName();
FooterBand->Top = DataBand->Top + DataBand->Height;
FooterBand->Height = HeaderBand->Height;
TfrxMemoView* totals = new TfrxMemoView(FooterBand);
totals->Top = 0;
totals->Left = 0;
totals->Height = 20;
totals->Align = baWidth;
bool is_error = false;
try
{
// ALL OF THESE LINES CAUSE THE ACCESS VIOLATION
// Create a summation function that displays the volume total
totals->Text = "Totals: [Sum(<ClientDataSet1.Volume>, MyDataBand, 1)]";
//totals->Text = "Totals: [Sum(<ClientDataSet1.'volume'>,MyDataBand,1)]";
//totals->Text = "Totals: [Sum(<ClientDataSet1.\"volume\">,MyDataBand,1)]";
//totals->Text = "Totals: [Sum(<ClientDataSet1.""volume"">,MyDataBand,1)]";
//totals->Text = "Totals: [Sum(<ClientDataSet1.''volume''>,MyDataBand,1)]";
//totals->Text = "Totals: [Sum(<ClientDataSet1.\'volume\'>,MyDataBand,1)]";
}
catch(Exception& e)
{
ShowMessage("ERROR: '" + e.Message + "'");
is_error = true;
}
if (!is_error)
{
frxReport1->ShowReport(true);
}
ClientDataSet1->Close();
ShowMessage("Program complete!");
Compile and run the program. The code in the try block will throw an access violation. Why is this happening? What is the correct syntax to create the sum formula?
UPDATE:
I modified the code by explicitly setting a name for frxDBDataset1:
frxReport1->Clear();
frxDBDataset1->DataSet = (TDataSet*)ClientDataSet1;
frxDBDataset1->Name = "frxDBDataset1"; // line added
frxReport1->DataSets->Add(frxDBDataset1);
I also changed the formula line to the following:
totals->Text = "Totals: [Sum(<frxDBDataset1.\"Volume\">, DataBand, 1)]";
I am still getting the access violation, though.
I was able to run without problems the following linked example, which includes the modifications we commented before.
https://www.dropbox.com/s/6grmajvoy9ijxfh/SO_test1.7z?dl=0
Go to Project --> Options --> Packages --> Runtime Packages. Set "Link with Runtime Packages" to False.
The default for this option is True for C++Builder, False for Delphi. This explains why the equivalent code worked in Delphi, but didn't work in C++Builder.
I have a asp.net form with 20 textbox controls(VB2012 and 2008R2). Is there an array function for me to change the property of all the fields or do I have to spell it out separately. Example changing the back color and making the control editable when the edit button is clicked.
Thanks
~ Nita
I did this sometime ago:
void SetEnabled(bool enable)
{
textBox1.enabled = enable;
textBox1.enabled = enable;
textBox2.enabled = enable;
textBox3.enabled = enable;
textBox4.enabled = enable;
textBox5.enabled = enable;
... repeat until textBox20
textBox20.enabled = enable;
}
to call it, for example:
SetEnabled(true);
or
SetEnabled(false);
I am new to the MVC Framework. Im working on a dashboard project in the MVC framework. The project consists of a bunch of charting control in a user controls contained in a master page. I did a test on a charting control on a aspx page..and it works...but when I moved the code to a ascx (usercontrol) the chart doesnt render. Any ideas?!?!?!...I'm stuck. Thanks in advance
Jeff
Code that is in in the .aspx
<%
System.Web.UI.DataVisualization.Charting.Chart Chart1 = new System.Web.UI.DataVisualization.Charting.Chart();
Chart1.Width = 450;
Chart1.Height = 296;
Chart1.RenderType = RenderType.ImageTag;
Chart1.ImageLocation = "..\\..\\TempImages\\ChartPic_#SEQ(200,30)";
Chart1.Palette = ChartColorPalette.BrightPastel;
Title t = new Title("Program Pipeline", Docking.Top, new System.Drawing.Font("Trebuchet MS", 14, System.Drawing.FontStyle.Bold), System.Drawing.Color.FromArgb(26, 59, 105));
Chart1.Titles.Add(t);
Chart1.ChartAreas.Add("Prog 1");
// create a couple of series
Chart1.Series.Add("Backlog");
Chart1.Series.Add("Constructed");
Chart1.Series.Add("Billed");
Chart1.Series.Add("BudgetUsed");
Chart1.Series.Add("Total");
Chart1.Series["Backlog"].ChartType = SeriesChartType.StackedBar100;
Chart1.Series["Constructed"].ChartType = SeriesChartType.StackedBar100;
Chart1.Series["Billed"].ChartType = SeriesChartType.StackedBar100;
Chart1.Series["Total"].ChartType = SeriesChartType.StackedBar100;
Chart1.Series["BudgetUsed"].ChartType = SeriesChartType.StackedBar100;
Chart1.Series["Backlog"]["DrawingStyle"] = "Cylinder";
Chart1.Series["Constructed"]["DrawingStyle"] = "Cylinder";
Chart1.Series["Billed"]["DrawingStyle"] = "Cylinder";
Chart1.Series["BudgetUsed"]["DrawingStyle"] = "Cylinder";
Chart1.Series["Total"]["DrawingStyle"] = "Cylinder";
// Bar Size
Chart1.Series["Backlog"]["PointWidth"] = "0.6";
Chart1.Series["Constructed"]["PointWidth"] = "0.6";
Chart1.Series["Billed"]["PointWidth"] = "0.6";
Chart1.Series["BudgetUsed"]["PointWidth"] = "0.6";
Chart1.Series["Total"]["PointWidth"] = "0.6";
int _total = 0;
int _newTotalAmt = 100 - _total;
foreach (MvcApplication1.Models.Amount obj in Model.GetTotalAmt("plm1"))
{
_total += obj.TotalAmount;
Chart1.Series[obj.PLMType].Points.AddY(obj.TotalAmount);
}
Chart1.Series["BudgetUsed"].Points.AddY(0);
Chart1.Series["Total"].Points.AddY(_newTotalAmt);
_total = 0;
_newTotalAmt = 100 - _total;
foreach (MvcApplication1.Models.Amount obj in Model.GetTotalAmtForPLM2("plm2"))
{
_total += obj.TotalAmount;
Chart1.Series[obj.PLMType].Points.AddY(obj.TotalAmount);
}
Chart1.Series["BudgetUsed"].Points.AddY(0);
Chart1.Series["Total"].Points.AddY(_newTotalAmt);
_total = 0;
_newTotalAmt = 100 - _total;
foreach (MvcApplication1.Models.Amount obj in Model.GetTotalAmt("plm3"))
{
_total += obj.TotalAmount;
Chart1.Series[obj.PLMType].Points.AddY(obj.TotalAmount);
}
Chart1.Series["BudgetUsed"].Points.AddY(0);
Chart1.Series["Total"].Points.AddY(_newTotalAmt);
// MvcApplication1.Models.TotalPOAmount oTotal = Model.GetOverAllBudget();
// add points to series 3
Chart1.Series["Billed"].Points.AddY(0);
Chart1.Series["Constructed"].Points.AddY(0);
Chart1.Series["Backlog"].Points.AddY(0);
Chart1.Series["BudgetUsed"].Points.AddY(39);
Chart1.Series["Total"].Points.AddY(100);
Chart1.BorderSkin.SkinStyle = BorderSkinStyle.Emboss;
Chart1.BorderColor = System.Drawing.Color.FromArgb(26, 59, 105);
Chart1.BorderlineDashStyle = ChartDashStyle.Solid;
Chart1.BorderWidth = 2;
Chart1.Legends.Add("Legend");
// show legend based on check box value
// Chart1.Legends["Legend1"].Enabled = ShowLegend.Checked;
// Render chart control
Chart1.Page = this;
HtmlTextWriter writer = new HtmlTextWriter(Page.Response.Output);
Chart1.RenderControl(writer);
//IList<SelectListItem> list = new List<SelectListItem>();
//SelectListItem sli = new SelectListItem();
//sli.Text = "test1";
//sli.Value = "1";
//list.Add(sli);
//ViewData["Test"] = list;
%>
I've had exactly the same issue. My problem was to do with the paths to the image file. The chart control was getting it wrong when placed on a usercontrol. If I changed the chart to use Imagestoragemode of HttpHandler then it worked as intended.
unfortunatly this stopped me being able to unit test my views. In the end I put the chart control on an aspx page & then used jQuery to load it when needed. (Luckily my dashboard page used javascript to load the contents of the portlets)
I've just been trying to get round what seems to be the same problem. When I moved the code (similar to yours above) to a UserControl the System.Web.UI.DataVisualization namespace wasn't recognised and I received the error:
The type or namespace name
'DataVisualization' does not exist in
the namespace 'System.Web.UI' (are you
missing an assembly reference?)
The namespace only seemed to be recognised when the Chart code lay within an asp control (in the aspx page it was within an <asp:Content> control). So I put the Chart code within an <asp:Panel> control and it worked.