Make progressbar appear on buttonclick in Windows Forms Powershell script?
Hello.
I am not very good at Powershell, so please bear with me if I ask questions which are easy to Powershell experts.
I have a Powershell script with 4 buttons, which each calls different .bat files I've written, to automatically backup my pictures and music and such, to my external harddrive and all that works perfectly.
Is there a way to make a marquee progressbar appear inside the window when a button is clicked? (strictly for good looks)
I have a code for a progressbar which works fine by itself, but can I make it appear when I click each button? Here is the code for the progressbar:
$progStrip = New-Object System.Windows.Forms.ProgressBar
$progStrip.Top = 70
$progStrip.Left = 10
$progStrip.Width = 515
$progStrip.Value = 0
$progStrip.Style="Marquee"
$progStrip.MarqueeAnimationSpeed = 50
$form.Controls.Add($progStrip)**
And here is my Powershell script with the button, that I want to trigger a progress bar, Marquee style for simplicity. Thank you very much in advance
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Application]::EnableVisualStyles()
$form = New-Object System.Windows.Forms.Form
$form.Size = New-Object System.Drawing.Size(550,210)
$form.Text = "System Backup"
$form.FormBorderStyle = "FixedDialog"
$form.StartPosition = "CenterScreen"
$form.KeyPreview = $True
$form.Add_KeyDown({if ($_.KeyCode -eq "Escape")
{$form.Close()}})
$icon = [system.drawing.icon]::ExtractAssociatedIcon('D:\Documents\Andet\Icons\icon1 (3).ico')
$form.Icon = $icon
$statStrip = New-Object System.Windows.Forms.StatusStrip
$statStrip.Items.Add("Backup via Powershell") | Out-Null
$form.Controls.Add($statStrip)
$1Button = New-Object System.Windows.Forms.Button
$1Button.Location = New-Object System.Drawing.Size(10,100)
$1Button.Size = New-Object System.Drawing.Size(125,40)
$1Button.Text = "Saved games backup"
$1Button.Add_Click({Start-Process "C:\Backup\Backup1.bat"})
$form.Controls.Add($1Button)
$2Button = New-Object System.Windows.Forms.Button
$2Button.Location = New-Object System.Drawing.Size(140,100)
$2Button.Size = New-Object System.Drawing.Size(125,40)
$2Button.Text = "Fuld backup til ekstern harddisk"
$2Button.Add_Click({Start-Process "C:\Backup\Backup2.bat"})
$form.Controls.Add($2Button)
$3Button = New-Object System.Windows.Forms.Button
$3Button.Location = New-Object System.Drawing.Size(270,100)
$3Button.Size = New-Object System.Drawing.Size(125,40)
$3Button.Text = "Slet og omdøb filer/mapper"
$3Button.Add_Click({Start-Process "C:\Backup\Delete.bat"})
$form.Controls.Add($3Button)
$4Button = New-Object System.Windows.Forms.Button
$4Button.Location = New-Object System.Drawing.Size(400,100)
$4Button.Size = New-Object System.Drawing.Size(125,40)
$4Button.Text = "Afslut"
$4Button.Add_Click({$form.Close()})
$form.Controls.Add($4Button)
$objLabel = New-Object System.Windows.Forms.Label
$objLabel.Location = New-Object System.Drawing.Size(185,15)
$objLabel.Size = New-Object System.Drawing.Size(200,50)
$objLabel.Font = New-Object System.Drawing.Font("Arial",15)
$objLabel.Text = "Vælg backup type:"
$form.Controls.Add($objLabel)
$form.Topmost = $True
$form.ShowDialog()
Thank you very much for your detailed reply.
Can you please show me a quick example, of how I can run multiple xcopy after one another, like "xcopy c:\test1 c:\test2" and then "xcopy c:\test3 c:\test4" when I click button 1, how would I write this bit then:
Thank you in advance.
$1Button = New-Object System.Windows.Forms.Button
$1Button.Location = New-Object System.Drawing.Size(10,100)
$1Button.Size = New-Object System.Drawing.Size(125,40)
$1Button.Text = "Saved games backup"
$1Button.Add_Click({Start-Process "C:\Backup\Backup1.bat"})
$form.Controls.Add($1Button)
Similar Messages
-
Hi my name is vishal
For past 10 days i have been breaking my head on how to make column headers in table appear bold while datas in table appear regular from c# windows forms with sql server2008 using iTextSharp.
Given below is my code in c# on how i export datas from different tables in sql server to PDF report using iTextSharp:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.Diagnostics;
using System.IO;
namespace DRRS_CSharp
public partial class frmPDF : Form
public frmPDF()
InitializeComponent();
private void button1_Click(object sender, EventArgs e)
Document doc = new Document(PageSize.A4.Rotate());
var writer = PdfWriter.GetInstance(doc, new FileStream("AssignedDialyzer.pdf", FileMode.Create));
doc.SetMargins(50, 50, 50, 50);
doc.SetPageSize(new iTextSharp.text.Rectangle(iTextSharp.text.PageSize.LETTER.Width, iTextSharp.text.PageSize.LETTER.Height));
doc.Open();
PdfPTable table = new PdfPTable(6);
table.TotalWidth =530f;
table.LockedWidth = true;
PdfPCell cell = new PdfPCell(new Phrase("Institute/Hospital:AIIMS,NEW DELHI", FontFactory.GetFont("Arial", 14, iTextSharp.text.Font.BOLD, BaseColor.BLACK)));
cell.Colspan = 6;
cell.HorizontalAlignment = 0;
table.AddCell(cell);
Paragraph para=new Paragraph("DCS Clinical Record-Assigned Dialyzer",FontFactory.GetFont("Arial",16,iTextSharp.text.Font.BOLD,BaseColor.BLACK));
para.Alignment = Element.ALIGN_CENTER;
iTextSharp.text.Image png = iTextSharp.text.Image.GetInstance("logo5.png");
png.ScaleToFit(105f, 105f);
png.Alignment = Element.ALIGN_RIGHT;
SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=DRRS;Integrated Security=true");
SqlCommand cmd = new SqlCommand("Select d.dialyserID,r.errorCode,r.dialysis_date,pn.patient_first_name,pn.patient_last_name,d.manufacturer,d.dialyzer_size,r.start_date,r.end_date,d.packed_volume,r.bundle_vol,r.disinfectant,t.Technician_first_name,t.Technician_last_name from dialyser d,patient_name pn,reprocessor r,Techniciandetail t where pn.patient_id=d.patient_id and r.dialyzer_id=d.dialyserID and t.technician_id=r.technician_id and d.deleted_status=0 and d.closed_status=0 and pn.status=1 and r.errorCode<106 and r.reprocessor_id in (Select max(reprocessor_id) from reprocessor where dialyzer_id=d.dialyserID) order by pn.patient_first_name,pn.patient_last_name", conn);
conn.Open();
SqlDataReader dr;
dr = cmd.ExecuteReader();
table.AddCell("Reprocessing Date");
table.AddCell("Patient Name");
table.AddCell("Dialyzer(Manufacturer,Size)");
table.AddCell("No.of Reuse");
table.AddCell("Verification");
table.AddCell("DialyzerID");
while (dr.Read())
table.AddCell(dr[2].ToString());
table.AddCell(dr[3].ToString() +"_"+ dr[4].ToString());
table.AddCell(dr[5].ToString() + "-" + dr[6].ToString());
table.AddCell("@count".ToString());
table.AddCell(dr[12].ToString() + "-" + dr[13].ToString());
table.AddCell(dr[0].ToString());
dr.Close();
table.SpacingBefore = 15f;
doc.Add(para);
doc.Add(png);
doc.Add(table);
doc.Close();
System.Diagnostics.Process.Start("AssignedDialyzer.pdf");
if (MessageBox.Show("Do you want to save changes to AssignedDialyzer.pdf before closing?", "DRRS", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation) == DialogResult.Yes)
var writer2 = PdfWriter.GetInstance(doc, new FileStream("AssignedDialyzer.pdf", FileMode.Create));
else if (MessageBox.Show("Do you want to save changes to AssignedDialyzer.pdf before closing?", "DRRS", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation) == DialogResult.No)
this.Close();
The above code executes well with no problem at all!
As you can see the file to which i create and save and open my pdf report is
AssignedDialyzer.pdf.
The column headers of table in pdf report from c# windows forms using iTextSharp are
"Reprocessing Date","Patient Name","Dialyzer(Manufacturer,Size)","No.of Reuse","Verification" and
"DialyzerID".
However the problem i am facing is after execution and opening of document is my
column headers in table in pdf report from
c# and datas in it all appear in bold.
I have browsed through net regarding to solve this problem but with no success.
What i want is my pdf report from c# should be similar to following format which i was able to accomplish in vb6,adodb with MS access using iTextSharp.:
Given below is report which i have achieved from vb6,adodb with MS access using iTextSharp
I know that there has to be another way to solve my problem.I have browsed many articles in net regarding exporting sql datas to above format but with no success!
Is there is any another way to solve to my problem on exporting sql datas from c# windows forms using iTextSharp to above format given in the picture/image above?!
If so Then Can anyone tell me what modifications must i do in my c# code given above so that my pdf report from c# windows forms using iTextSharp will look similar to image/picture(pdf report) which i was able to accomplish from
vb6,adodb with ms access using iTextSharp?
I have approached Sound Forge.Net for help but with no success.
I hope anyone/someone truly understands what i am trying to ask!
I know i have to do lot of modifications in my c# code to achieve this level of perfection but i dont know how to do it.
Can anyone help me please! Any help/guidance in solving this problem would be greatly appreciated.
I hope i get a reply in terms of solving this problem.
vishalHi,
About iTextSharp component issue , I think this case is off-topic in here.
I suggest you consulting to compenent provider.
http://sourceforge.net/projects/itextsharp/
Regards,
Marvin
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
How to Turn On/Off Airplane mode in windows through powershell script
I want to turn on and off Airplane mode through powershell script, any way for this?
I know that there are some exe files that can be used, but still I want to do this from powershell script.Hi,
According to your description, I would like to share the link with you:
Airplane Mode On or Off Shortcuts - Create in Windows 8
http://www.eightforums.com/tutorials/24541-airplane-mode-off-shortcuts-create-windows-8-a.html
If you want to the detail of the script, I suggest to post the question on Script Center forum for further help.
Script Center forum:
http://social.technet.microsoft.com/Forums/scriptcenter/en-US/home
Note: Microsoft provides third-party contact information to help you find technical support. This contact information may change without notice. Microsoft does not guarantee the accuracy of this third-party contact information.
Regards,
Kelvin_Hsu
TechNet Community Support -
[bash] make command appear in new terminal window
I have a bash command that uses aria2 to download something. The problem is that it download silently in the background. I want it to display in a new terminal window so I can see the download stats. How can I do this?
urxvt -e "some_command" ?
-
Exclude a KB number from a Windows update Powershell Script.
I am having a heck of a time removing a patch from the $updates patch collection. We have one that we do not want to install. Using attempts like $updates.remove are not working. Has anyone accomplished this before?
thanks
$updateSession = new-object -com "Microsoft.Update.Session"
Write-Host("Searching for applicable updates...") -Fore Green
$updates=$updateSession.CreateupdateSearcher().Search($criteria).Updates
$downloader = $updateSession.CreateUpdateDownloader()
$downloader.Updates = $Updates
foreach ($y in $updates){$y.kbarticleIDs}
(section to remove a KB from $updates, based on KB)Here is a little script that will create a hash table of all applicable updates, and their associated UUID's. This can be used to look up the UUID, to use as a criteria when searching again:
$upids = @{}
$Searcher = New-Object -ComObject Microsoft.Update.Searcher
$results = $searcher.search("Type='software' AND IsInstalled = 0")
$Results.Updates |
ForEach-Object { $upids.Add($_.Title, $_.Identity.UpdateID) }
$upids
([string](0..9|%{[char][int](32+("39826578846355658268").substring(($_*2),2))})).replace(' ','')
What's new in Powershell 3.0 (Technet Wiki) -
Activate windows using powershell
I am after a PowerShell script which can check for OS ,check channel for example if it is on MAK then replace it with a KMS channel and then update windows with a generic KMS key and then activate windows . From command prompt I achieve it
using
slmgr /dlv - >to check for channel, If its set to MAK then replace it to KMS using
slmgr /ipk "KMS generic key as per OS Version "
and then activate windows using
slmgr /ato
FaizanHi Faizan,
Please note you can also use the cmd "slmgr" in Windows Powershell.
If you want to activate Windows via powershell script, please check the WMI class SoftwareLicensingService.
The script below can install the appropriate KMS client key for the detected OS:
$OSversion = (Get-WmiObject -class Win32_OperatingSystem).Caption
switch -Regex ($OSversion) {
'Windows 8.1 Professional N' {$key = 'HMCNV-VVBFX-7HMBH-CTY9B-B4FXY';break}
'Windows 8.1 Professional' {$key = 'GCRJD-8NW9H-F2CDX-CCM8D-9D6T9';break}
'Windows 8.1 Enterprise N' {$key = 'TT4HM-HN7YT-62K67-RGRQJ-JFFXW';break}
'Windows 8.1 Enterprise' {$key = 'MHF9N-XY6XB-WVXMC-BTDCT-MKKG7';break}
'Windows Server 2012 R2 Standard' {$key = 'D2N9P-3P6X9-2R39C-7RTCD-MDVJX';break}
'Windows Server 2012 R2 Datacenter' {$key = 'W3GGN-FT8W3-Y4M27-J84CP-Q3VJ9';break}
$KMSservice = Get-WMIObject -query "select * from SoftwareLicensingService"
Write-Debug 'Activating Windows.'
$null = $KMSservice.InstallProductKey($key)
$null = $KMSservice.RefreshLicenseStatus()
Refer to:
Auto-activate a non-domain joined Windows OS using Powershell and a domain KMS host
Activating Windows with PowerShell
If there is anything else regarding this issue, please feel free to post back.
Best Regards,
Anna Wang
TechNet Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected] -
Could i use visual studio to make a windows form that could interact with facebook?
I'm a beginner to windows forms and have just read my way through tutorials at learnc++.com so i want to get started on a project to practice my c++ and also a project that i could find usefull.
What I want to do is check a facebook group page every minute for new posts that contain certain words. So im thinking i could make a web browser and then get the document from the facebook group page and extract the html from it to search for certain keywords.
I realize that I won't be able to just do this straight away and will have to learn more about certain functions and how to get html from a webpage. Where can i learn the skills I would need to be able to do this? I'm going to try searching youtube for related
tutorials and I'm guessing that this site has all the documentation i will need to understand the functions to pull the html from a webpage.
please help me to figure out how I could achieve this, if i haven't been clear I will try to reply to any questions you have.
Thanks for reading,
JakeHello,
I'd search over here:
https://developers.facebook.com/
Karl
When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
My Blog: Unlock PowerShell
My Book:
Windows PowerShell 2.0 Bible
My E-mail: -join ('6F6C646B61726C406F75746C6F6F6B2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}}) -
How do I view what slide I'm on out of how many I have total in keynote? I know on powerpoint it's at the bottom right of the window but I can't find it on keynote, nor can I find the option to make it appear. Any help would be greatly appreciated.
Your steps so far are OK but you may want to try:
1 Trash your user library Caches folder (House Icon with short name in Finder window (hard drive window)GOTO:House icon > Library folder > caches folder
2 Trash the com.apple.Safari.plist file in User library > preferences folder > Safari.plist as well as removing the library Safari folder its self.
3 you can selectivly re-install Safari 2.0 from your OS Tiger Install disk 1, (see Knowledge base article 301229 for how to just select the Safari Application) without doing a complete system Archive and Install.
4. Create a new Test user account on the system and test how Safari responds in the Test user, see if its a user related issue and not system issue.
5. Still no Safari response? have to do an Archive and install (not preserving user and network settings)article 107120
PS. Issue may be related to actual internet connection connectivity, power cycle cable modem and router or airport if using one as well as the computer(keep unplugged for 3-5 min) and plug the cable modem in and then the router/airport then power on the computer. Do the Airport Admin utiliy (applications, utilities on HD_1)update.
- do a hard reset of airport knowledge base article 108044(Express base) and 107451 (Extreme base)
- Check with internet provider for connection issues "cannot find server" ect. -
Under bookmarks the Organize bookmark option does not appear, new computer Firefox 4.0, and Windows 7, how to make it appear, thanks
"Organize Bookmarks" has been renamed to "Show All Bookmarks" in the bookmarks menu.
-
How to make log in windows form application
I am trying to build a program with log in at the start
i was doing this log in by make a global class on program.cs file
and this global contain : id and name to know who is the user
is that correct or there is a better way to do that ?i am talking about windows form not wpf
Hello,
Maybe we should focus on the nice tool shared by darnold924 instead of just noticing that sample is wpf.
We could make sure that tool also works for winform applications, you could refer to the following document.
#Configure Log4Net for Desktop and Web Applications
http://www.codeproject.com/Articles/11328/Configure-Log-Net-for-Desktop-and-Web-Applications
Regards,
Carl
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
I Need Help Trying to Play (.pls) files in a simple windows forms Application
So I'm try to build application that when I click on the icon it opens a little window and play the url .pls. I already got the graphics of the app i just to get the code and I've been looking around for but all i got was this code
typedef struct
int count;
void **name;
void **displayname;
} Playlist;
Playlist* my_playlist; // SHOUTCAST PLAYLIST
#define BOX(text) MessageBox(NULL,text,"Info",MB_OK | MB_TOPMOST);
char *stristr(char *string2, char *string1) // from /samples/fmod/Main.c
char *s1 = strdup(string1);
char *s2 = strdup(string2);
char *ret = 0;
int i, j;
int len1 = (int)strlen(string1);
int len2 = (int)strlen(string2);
for (i=0;s1[i];i++) s1[i] = tolower(s1[i]);
for (i=0;s2[i];i++) s2[i] = tolower(s2[i]);
for (j=0;j < (len2 - len1);j++)
char *a = s1;
char *b = &s2[j];
for (i=0;(i < len1) && *a && *b;a++, b++, i++)
if (*a != *b)
break;
if (i == len1)
ret = &string2[j];
break;
free(s1);
free(s2);
return ret;
Playlist *ParsePlaylist(char *name) // from /samples/fmod/Main.c and MSDN
char *filebuf, *p;
Playlist *playlist = 0;
int count, i;
// Check if URL is null
if (!name)
BOX("Streaming URL is empty");
return 0;
// Check if URL is a *.pls file
if (_stricmp((const char *)".pls", (const char *)(&name[strlen(name) - 4])))
return 0;
// Create a WinInet session
HINTERNET hSession = InternetOpen(_T(""), INTERNET_OPEN_TYPE_PRECONFIG, 0, 0, 0);
// Prepare a request
HINTERNET hRequest = InternetOpenUrl(hSession, name, 0, 0, 0, 0);
// Send the HTTP request.
HttpSendRequest(hRequest, 0, 0, 0, 0);
// Read the response data.
DWORD dwNumberOfBytesAvailable = 0;
do
// Retrieve size of remote file
InternetQueryDataAvailable(hRequest, &dwNumberOfBytesAvailable, 0, 0);
if (0 < dwNumberOfBytesAvailable)
// Allocate buffer memory
filebuf = new char[dwNumberOfBytesAvailable + 1];
filebuf[dwNumberOfBytesAvailable] = 0;
DWORD dwBytesRead = 0;
// Read remote file and put in buffer
InternetReadFile(hRequest,
filebuf,
dwNumberOfBytesAvailable,
&dwBytesRead);
//BOX(filebuf);
while (0 < dwNumberOfBytesAvailable);
// Close the request handle.
InternetCloseHandle(hRequest);
// Close the WinInet session.
InternetCloseHandle(hSession);
// Parse the pls file (from Fmod sample)
p = stristr(filebuf, "NumberOfEntries=");
if (!p)
BOX("Streaming : NumberOfEntries in pls file not found");
return 0;
p += 16;
count = atoi(p);
if (!count)
BOX("Streaming : numeric value for NumberOfEntries not found");
return 0;
playlist = (Playlist *)calloc(sizeof(Playlist), 1);
if (!playlist)
BOX("Streaming : can't allocate memory for pls file (playlist)");
return 0;
playlist->count = count;
playlist->name = (void **)calloc(sizeof(char *) * count, 1);
if (!playlist->name)
BOX("Streaming : can't allocate memory for pls file (playlist->name)");
return 0;
playlist->displayname = (void **)calloc(sizeof(char *) * count, 1);
if (!playlist->displayname)
BOX("Streaming : can't allocate memory for pls file (playlist->displayname)");
return 0;
for (i=0;i < count;i++)
char tmp[32];
char *filename, *displayname, *t;
filename = displayname = 0;
sprintf(tmp, "File%d=", i + 1);
p = strstr(filebuf, tmp);
if (p)
p += strlen(tmp);
t = p;
for (;*t && (*t != 0xa) && (*t != 0xd);t++);
if (*t)
char tmpc = *t;
*t = 0;
filename = _strdup(p);
*t = tmpc;
if (strncmp(filename, "http://", 7) && strncmp(filename, "http:\\\\", 7))
char *tmpname = _strdup(filename);
p = &tmpname[strlen(tmpname) - 1];
for (;(p > tmpname) && (*p != '\\') && (*p != '/');p--);
if ((*p == '\\') || (*p == '/'))
p++;
displayname = _strdup(p);
free(tmpname);
playlist->name[i] = filename;
playlist->displayname[i] = displayname;
free(filebuf);
return playlist;
[main code]
char string_music[256] = "http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=6042&file=filename.pls"; // For example
// Parse the remote file (in case it's a Shoutcast playlist (*.pls))
my_playlist = ParsePlaylist(string_music);
if (my_playlist)
strcpy(string_music, (char*) my_playlist->name[0]); // for the first song in the playlist
FSOUND_STREAM * my_stream = FSOUND_Stream_Open(string_music, FSOUND_NORMAL | FSOUND_NONBLOCKING, 0, 0);
int int_sound_mp3 = FSOUND_Stream_Play(FSOUND_FREE, my_stream);
and i got to link it to Wininet.lib
and I'm a noob so i got problems as soon as i tried to put everything together
so any help greatly appreciated
BTW if you know any other ways, that I'll be able to stream the audio that will be great to.
heres the link for the audio stream (.pls)
http://panel3.serverhostingcenter.com:2199/tunein/nrlsxglp.plsHello 0cooldex0,
What library do you used in this scenario? I haven't saw this FSOUND_STREAM from MSDN library.
By the way, winform general is used for talking about Windows Form library, is is using C# or VB.NET but not C or C++. You are not posting in the right forum.
In my point of view, you may choose the forum depending on the library you choosed and post on specific forum.
Regards,
Barry
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Crystal Report Windows Forms Viewer - No Error Popup
Similar to this post: Error message that says "No Error" from CR Viewer, I have just upgraded by Application to .net 4.0 and Crystal Reports 2010. The report viewer works fine the first time a report is loaded, but when I change the parameters on the report, and put the updated report back into the report viewer, I get the message shown above. The report does not change its parameters and the updated report is not displayed. The code in question is setting the date parameters for the report. The user can select new date parameters from the form that encloses the report viewer. The code subclasses the Report Object code to add additional functions through interfaces. The IDateRange interface provides a starting and ending date range for the report using a property on the report class as follows:
Public Property EndingDate() As Date Implements IDateRange.EndingDate
Get
Return _endingDate
End Get
Set(ByVal value As Date)
_endingDate = value
Me.SetParameterValue("EndingDate", value)
End Set
End Property
In addition, the immediate Window shows the following message:
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in CrystalDecisions.CrystalReports.Engine.dll
The code in the Report Viewer looks like this, see line marked in blue for when pop-up appears:
''' <summary>
''' Sets the report period and displays it.
''' </summary>
''' <param name="Report">The Report.</param>
''' <param name="Refresh">if set to <c>true</c> force a refresh.</param>
Private Function PFSetReportPeriod(ByVal Report As Object, Optional ByVal Refresh As Boolean = True) As Boolean
Dim fld As FormulaFieldDefinition
Dim bRefresh As Boolean = False
Dim rpt As ReportClass = CType(Report, ReportClass)
Try
If CRV.ReportSource IsNot Nothing Then
rpt = CType(CRV.ReportSource, ReportClass)
End If
If TypeOf rpt Is IDateRange Then
With DirectCast(rpt, IDateRange)
. StartingDate = dtpFromDate.Value
. EndingDate = dtpToDate.Value
End With
SetTitleLine2(DirectCast(Report, ReportClass), bRefresh)
bRefresh = True
Else
If TypeOf rpt Is ReportClass Then
fld = rpt.DataDefinition.FormulaFields("FromDate")
If Not fld Is Nothing Then
fld.Text = "Date(" & dtpFromDate.Value.Year & "," & dtpFromDate.Value.Month & "," & dtpFromDate.Value.Day & ")"
bRefresh = True
End If
fld = rpt.DataDefinition.FormulaFields("ToDate")
If Not fld Is Nothing Then
fld.Text = "Date(" & dtpToDate.Value.Year & "," & dtpToDate.Value.Month & "," & dtpToDate.Value.Day & ")"
bRefresh = True
End If
SetTitleLine2(rpt, bRefresh)
End If
End If
If Refresh And bRefresh Then
If dtpToDate.Value <> CDate(dtpToDate.Tag) OrElse _
dtpFromDate.Value <> CDate(dtpFromDate.Tag) Then
System.Windows.Forms.Application.DoEvents()
If CRV.Visible Then CRV.ReportSource = rpt ' The popup appears when this statement is executed.
If CRV.Visible = True Then CRV.Refresh()
dtpToDate.Tag = dtpToDate.Value
dtpFromDate.Tag = dtpFromDate.Value
Return True
End If
End If
Catch ex As Exception
DisplayException(ex)
End Try
Return False
End FunctionProblem has been resolved. I downloaded Support Pack 8 (v.13.0.8.1216) from this location. I then applied the fix from the entry above:
With CRV ' Report Viewer Control
If .Visible Then
If .ParameterFieldInfo IsNot Nothing Then .ParameterFieldInfo.Clear()
.ReportSource = rpt
.Refresh()
End If
End With
And no more annoying "No Error" messages. -
Hi for past 3 days i was thinking and breaking my head on how to add entire new at top table created in pdf report from c# windows forms with iTextSharp.
First: I was able to create/export sql server data in form of table in pdf report from c# windows forms. Given below is the code in c#.
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Text;
using System.Data;
using System.IO;
using System.Data.SqlClient;
using System.Windows.Forms;
using iTextSharp.text;
using iTextSharp.text.pdf;
namespace DRRS_CSharp
public partial class frmPDFTechnician : Form
public frmPDFTechnician()
InitializeComponent();
private void btnExport_Click(object sender, EventArgs e)
Document doc = new Document(PageSize.A4.Rotate());
var writer= PdfWriter.GetInstance(doc, new FileStream("Technician22.pdf", FileMode.Create));
doc.SetMargins(50, 50, 50, 50);
doc.SetPageSize(new iTextSharp.text.Rectangle(iTextSharp.text.PageSize.LETTER.Width, iTextSharp.text.PageSize.LETTER.Height));
doc.Open();
PdfPTable table = new PdfPTable(7);
table.TotalWidth=585f;
table.LockedWidth = true;
PdfPTable inner = new PdfPTable(1);
inner.WidthPercentage = 115;
PdfPCell celt=new PdfPCell(new Phrase(new Paragraph("Institute/Hospital:AIIMS,NEW DELHI",FontFactory.GetFont("Arial",14,iTextSharp.text.Font.BOLD,BaseColor.BLACK))));
inner.AddCell(celt);
Paragraph para = new Paragraph("DCS Clinical Report-Technician wise", FontFactory.GetFont("Arial", 14, iTextSharp.text.Font.BOLD, BaseColor.BLACK));
para.Alignment = iTextSharp.text.Element.TITLE;
iTextSharp.text.Image png = iTextSharp.text.Image.GetInstance("logo5.png");
png.ScaleToFit(95f, 95f);
png.Alignment = Element.ALIGN_RIGHT;
SqlConnection conn=new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=DRRS;Integrated Security=true");
SqlCommand cmd = new SqlCommand("Select t.technician_id,td.Technician_first_name,td.Technician_middle_name,td.Technician_last_name,t.technician_dob,t.technician_sex,td.technician_type from Techniciandetail td,Technician t where td.technician_id=t.technician_id and td.status=1", conn);
conn.Open();
SqlDataReader dr;
dr = cmd.ExecuteReader();
table.AddCell("ID");
table.AddCell("First Name");
table.AddCell("Middle Name");
table.AddCell("Last Name");
table.AddCell("DOB" );
table.AddCell("Gender");
table.AddCell("Designation");
while (dr.Read())
table.AddCell(dr[0].ToString());
table.AddCell(dr[1].ToString());
table.AddCell(dr[2].ToString());
table.AddCell(dr[3].ToString());
table.AddCell(dr[4].ToString());
table.AddCell(dr[5].ToString());
table.AddCell(dr[6].ToString());
dr.Close();
table.SpacingBefore = 15f;
doc.Add(para);
doc.Add(png);
doc.Add(inner);
doc.Add(table);
doc.Close();
The code executes well with no problem and get all datas from tables into table in PDF report from c# windows forms.
But here is my problem how can i align Title(DCS Clinical Report-Technician wise) center of pdf report with image named:logo5.png immediately coming to it's right?.
As the problem i am facing is my title or Header(DCS Clinical Report-Technician wise) is at top of my image named:logo5.png and not coming to it's center position of my image.
Second the problem i am facing is how to add new entire row to top of existing table in pdf report from c# windows form using iTextSharp?.
given in below is the row and it's data . So how do i add the given below row and it's data to my top my table in pdf report from c# windows forms using itextsharp?
as you can see how i create my columns in table in pdf report and populate it with sql server data. Given the code below:
Document doc = new Document(PageSize.A4.Rotate());
var writer= PdfWriter.GetInstance(doc, new FileStream("Technician22.pdf", FileMode.Create));
doc.SetMargins(50, 50, 50, 50);
doc.SetPageSize(new iTextSharp.text.Rectangle(iTextSharp.text.PageSize.LETTER.Width, iTextSharp.text.PageSize.LETTER.Height));
doc.Open();
PdfPTable table = new PdfPTable(7);
table.TotalWidth=585f;
table.LockedWidth = true;
Paragraph para = new Paragraph("DCS Clinical Report-Technician wise", FontFactory.GetFont("Arial", 14, iTextSharp.text.Font.BOLD, BaseColor.BLACK));
para.Alignment = iTextSharp.text.Element.TITLE;
iTextSharp.text.Image png = iTextSharp.text.Image.GetInstance("logo5.png");
png.ScaleToFit(95f, 95f);
png.Alignment = Element.ALIGN_RIGHT;
SqlConnection conn=new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=DRRS;Integrated Security=true");
SqlCommand cmd = new SqlCommand("Select t.technician_id,td.Technician_first_name,td.Technician_middle_name,td.Technician_last_name,t.technician_dob,t.technician_sex,td.technician_type from Techniciandetail td,Technician t where td.technician_id=t.technician_id and td.status=1", conn);
conn.Open();
SqlDataReader dr;
dr = cmd.ExecuteReader();
table.AddCell("ID");
table.AddCell("First Name");
table.AddCell("Middle Name");
table.AddCell("Last Name");
table.AddCell("DOB" );
table.AddCell("Gender");
table.AddCell("Designation");
while (dr.Read())
table.AddCell(dr[0].ToString());
table.AddCell(dr[1].ToString());
table.AddCell(dr[2].ToString());
table.AddCell(dr[3].ToString());
table.AddCell(dr[4].ToString());
table.AddCell(dr[5].ToString());
table.AddCell(dr[6].ToString());
dr.Close();
table.SpacingBefore = 15f;
doc.Add(para);
doc.Add(png);
doc.Add(table);
doc.Close();
So my question is how to make my column headers in bold?
So these are my questions.
1. how can i align Title(DCS Clinical Report-Technician wise) center of pdf report with image named:logo5.png immediately coming to it's right?.
2. how do i add the given below row and it's data to my top my table in pdf report from c# windows forms using itextsharp?
3.how to make my column headers in bold?
I know that i have to do some modifications to my code but i dont know how to do it. Can anyone help me please.
Any help or guidance in solving this problem would be greatly appreciated.
vishalHi,
>>1. how can i align Title(DCS Clinical Report-Technician wise) center of pdf report with image named:logo5.png immediately coming to it's right?.
2. how do i add the given below row and it's data to my top my table in pdf report from c# windows forms using itextsharp?
3.how to make my column headers in bold?<<
I’m sorry for the issue that you are hitting now.
This itextsharp is third party control, for this issue, I recommended to consult the control provider directly, I think they can give more precise troubleshooting.
http://sourceforge.net/projects/itextsharp/
Thanks for your understanding.
Regards,
Marvin
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Need help with an Aforge and windows forms memory stack-up issue
Hello,
I am experiencing a strange memory stack-up in my c# windows form program that occurs all the time on slow PCs, and when the windows form loses focus or is otherwise interrupted on faster PCs.
The program I have written uses Aforge to get images from my webcam, which I then display in an Aforge picturebox control (CurrImagePic in code) in the windows form. The images are switched into the picture box and then disposed at the camera's native
framerate, so it appears as video to the user, not still images. The picture box is 1080x1920, but the space for it in the form is smaller and so I allow the user to scroll around the picture.
After about ~30 seconds of memory-stable operation on slower PCs, the problem begins. On faster PCs, the problem only occurs when holding down scroll bar arrows or clicking and dragging around either scroll bar, and if I lock the PC or bring up the
Ctrl+Alt+Delete menu.
The problem itself is that memory used by the program starts to increase in very large chunks, leading to an out of memory crash. This is unstoppable on slower PCs, but on the faster PCs if you stop scrolling or return from the lock/Ctrl+alt+delete
menu, the program stabilizes at the higher memory usage level. The memory that was accrued during scrolling or while in the lock menu is never collected by the garbage collector. I've even tried to put in a button that forces a GC.collect() when
pressed, and it does not reduce this memory usage.
I've run perfmon and found that the memory increase is on the unmanaged heap, but I don't know if it's coming from bitmaps which are not being disposed or what it could be from. It's been impossible to track down since it does not occur except in the
above conditions. I've tried various solutions (like moving my image processing out of the event handler and even using both global flags and a "lock" statement to try and ensure that only one thread or frame can access the image processing
and displaying method at at time, but I have seen no change. In fact, I am now seeing some unexplained small jumps in memory usage that I wasn't seeing before I put in the lock and moved the processing out of the handler.
Has anyone run into situations like this? I am at a loss for what I need to fix. I think the problem is based around my Aforge event handler and image processing method if it is in my code at all - but I also have a suspicion that this is something
deeper in the windows form code that I am either misusing or that can't keep up with the demands of my code. Code below:
//Applicable Globals to this code snippet
private bool ALLOWFRAME = true;
private Object FRAMEKEY = new Object();
private VideoCaptureDevice COMPVID;
private Bitmap TMPLTCAP;
private System.Drawing.Image OLDIMAGE;
private bool RCRDPIC = false;
private void COMPVID_NewFrame(object sender, NewFrameEventArgs eventArgs)
//Only process a frame when another is done processing
if (ALLOWFRAME == true)
ALLOWFRAME = false;
Bitmap PassFrame = AForge.Imaging.Image.Clone(eventArgs.Frame);
ProcessFrame(PassFrame);
PassFrame.Dispose();
private void ProcessFrame(Bitmap frameIn)
lock (FRAMEKEY)
if (OLDIMAGE != null) { OLDIMAGE.Dispose(); }
//Call comparison method if flag is set.
if (COMPON == true)
Difference TmpltFilter = new Difference(TMPLTCAP);
TmpltFilter.ApplyInPlace(frameIn);
OLDIMAGE = CurrImagePic.Image;
CurrImagePic.Image = AForge.Imaging.Image.Clone(frameIn);
OLDIMAGE.Dispose();
else
OLDIMAGE = CurrImagePic.Image;
CurrImagePic.Image = AForge.Imaging.Image.Clone(frameIn);
OLDIMAGE.Dispose();
//Toggle the flag back to false to show it's safe (i.e., comparisons have stopped)
//for the result-recording method to copy from the picture box if it is attempting to copy
if (RCRDPIC == true)
RCRDPIC = false;
ALLOWFRAME = true;As you are using third party tools and controls, and I cannot find posts on parallel cases using native VS controls, have you asked in the Aforge forums about your memory issue?
http://www.aforgenet.com/aforge/framework/ -
Error message when displaying a report in a windows form
Hi,
use Cr 2008.SP3 Fixpack 3.5,
Visual Studio 2008 prof. editon version 9.0.30729.1 SP,
:NET Framework 3.5 sp1
vb.net 2008
when displaying a report in a Windows form sometimes the following error message appears
System.NullReferenceException: Object reference not set to an instance of an object
bei CrystalDecisions.Windows.Forms.PageControl.OnMouseMove(MouseEventArgs e)
bei System.Windows.Forms.Control.WmMouseMove(Message& m)
bei System.Windows.Forms.Control.WndProc(Message& m)
bei System.Windows.Forms.ScrollableControl.WndProc(Message& m)
bei System.Windows.Forms.ContainerControl.WndProc(Message& m)
bei System.Windows.Forms.UserControl.WndProc(Message& m)
bei CrystalDecisions.Windows.Forms.PageControl.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
The rest of the error message is in german:
************** JIT-Debuggen **************
Um das JIT-Debuggen (Just-In-Time) zu aktivieren, muss in der
Konfigurationsdatei der Anwendung oder des Computers
(machine.config) der jitDebugging-Wert im Abschnitt system.windows.forms festgelegt werden.
Die Anwendung muss mit aktiviertem Debuggen kompiliert werden.
Zum Beispiel:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
Wenn das JIT-Debuggen aktiviert ist, werden alle nicht behandelten
Ausnahmen an den JIT-Debugger gesendet, der auf dem
Computer registriert ist, und nicht in diesem Dialogfeld behandelt.
Thank you
OttoCan you define "sometimes" a bit more?
Is it after a number of runs of a report?
Is it on a particular report?
Is it after you do certain operations on the report (paging, zooming, dill down, print, etc., etc.)?
Can you duplicate the issue if you isolate the report to a new test app?
Did you happen to notice if the issue existed prior to FP 3.5?
Is this on your dev computer or a client computer?
OS?
Ludek
Follow us on Twitter http://twitter.com/SAPCRNetSup
Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]
Maybe you are looking for
-
Safari 6 don't work in OsX 10.7.4 version ?
It's been a long time since I can't use Safari in my computer. When I click on the icon the safari wondow opens up, but it answers no comands. Makes nothing. You know how can I solve this problem?
-
Old FM line item not found at time of GR reversal
Hi Gurus, Happy new Year 2010, Scenario: My client has created pr and po in 2007 and done migo in 2008 . Account assignment-P they assigned WBS as well as Fund center and commitment also. During 2007 they have deactivated the derivation rule and cre
-
Hello just got my MacBook pro but cant migrate my pc info yo the mac tried three times gets as far as trying to transfer music then stops any ides thanks
-
i downloaded a video which is in avi. fomat but my mac only plays 3 sec of the video how do i get it to play the hold thing
-
Unity - How do I turn off voicemail message "your mailbox is almost full"?
We recently set a mailbox limit on our exchange server. Some users are over the limit until they deuce their mailbox size. When they check their messages via the 7940 "messages" button, they get the message "Your mailbox is almost full?etc" before it