Is there a click event/property for the Report Viewer which can return to me what they are clicking on?
The report designer is limited to:
Go to Report
Go to bookmark
Go to url
My report has a field with a file name, I would like to write into my Double Click Event to open the containing folder on DoubleClick.
I dont need help with the code for opening the folder, just on getting what is being doubleclicked on so I can open the correct folder. Something like
private void rptvReport_DoubleClick(object sender, EventArgs e)
{
MessageBox.Show(rptvReport.**CURRENTITEM**.text);
}
In your report set the textbox action to "go to Url" and the expression for the url set it to:
="http://someaction?rowid="+Trim(Str(Fields!SomeIdField.Value))
Then in your form use the "Hyperlink" event of the report viewer control:
uxReportViewer.Hyperlink += uxReportViewer_Hyperlink;
And in the eventhandler:
void uxReportViewer_Hyperlink(object sender, HyperlinkEventArgs e)
{
Uri link = new Uri(e.Hyperlink);
if (link.Authority == "someaction")
{
e.Cancel = true; //Cancel the event to avoid opening the browser
char[] sep=new char[] {'='};
var param=link.Query.Split(sep);
string rowId=param[1];
MessageBox.Show("You clicked on Id: "+rowId.ToString());
}
}
You can extend this for different actions and more than one parameter
Related
I'm working on Visual Studio, in C# language
I would like to ask if there's someway to go back to get the ButtonX.Text I pressed on the previous page, some sort of Login without a password.
Basically I need a worker to specify which person he is by clicking on their name (button) then it goes foward to the next page I have a label on the MasterPage but it resets everytime it goes on a next page what I would like to do is keep the info there
If you need some code tell me.
Thanks
You could use session variables?
On the button click handler on the first page...
protected void button_Click(object sender, EventArgs e)
{
Session["Worker"] = button.Text;
}
Then on the second page...
Label.Text = Session["Worker"];
Based-off your reply to Zollistic's answer, you could do this...
Apply this event to all your all your worker buttons...
protected void button_Click(object sender, EventArgs e)
{
if (Session["Worker"] == null) Session["Worker"] = "";
Session["Worker"] += button.Text + ",";
}
Now Session["Worker"] has a character-delimited list of all the clicked buttons. The character in this example is a comma; but you can change it to whatever you want (i.e. a pipe "|").
First, I am using Visual Studio 2013 and coding in C# to develop a Windows Form Application. I have added the "System.IO" namespace.
I need to show a directory path in a textbox when selected by the user.
The code works correctly to where the user selects a folder from a popup
and presses the OK button, which then displays the number of files within
that folder -- but the folder path does NOT get displayed as I desired.
Code looks like this:
private void button1_Click(object sender, EventArgs e)
{
//
// This event handler was created by clicking the button in the application GUI.
//
DialogResult button1_Click = folderBrowserDialog1.ShowDialog();
if (button1_Click == DialogResult.OK)
{
//
// The user selected a folder and pressed the OK button.
// A message pops up and identifies the number of files found within that folder.
//
string[] files = Directory.GetFiles(folderBrowserDialog1.SelectedPath);
MessageBox.Show("Files found: " + files.Length.ToString(), "Message");
}
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
string path;
path = folderBrowserDialog1.SelectedPath;
// folderBrowserDialog1.ShowDialog(); // NOT SURE ABOUT USING THIS!
textBox1.Text = path;
}
You could just add this to the end of your button1_Click method (inside the if block):
textBox1.Text = folderBrowserDialog1.SelectedPath;
How can i add the mechanism in my downloader for the case although many threads on SO deals either with php etc and not upto the need.
I have a browse button at the front of a textbox where i get's the user entered Path on local drive to fix the location for downloading but i have already hardcoded one for system drive.I want textbox button to be disabled unless user clciks browse button and then new path can be entered for downloading after then.
How can i go?
A quick example:
private void browseButton_Click(object sender, EventArgs e)
{
var saveFileDialog = new System.Windows.Forms.SaveFileDialog();
var selectedPath= saveFileDialog.ShowDialog();
if (selectedPath == System.Windows.Forms.DialogResult.OK)
{
_savePath = saveFileDialog.FileName;
textBox1.Enabled = true;
textBox1.Text = _savePath;
}
}
Is there an easy way to show an dialog when the program is started for the first time (and only the first time), for some kind of instruction or specifying settings?
You could save it as a bool in your settings and you should check at load event of first form.
Your settings file should have a setting that I called "FirstRun" do this with following steps:
Right click your Project
Click "Properties"
Click "Settings" tabpage(probably on the left)
Add setting like I did as seen in image above
Note: The Scope can be changed to "Application", if that is your application's need, since you didn't mention in your question.
Your Settings file should look like image below:
public void Form1_Load(object sender, EventArgs e)
{
if((bool)Properties.Settings.Default["FirstRun"] == true)
{
//First application run
//Update setting
Properties.Settings.Default["FirstRun"] = false;
//Save setting
Properties.Settings.Default.Save();
//Create new instance of Dialog you want to show
FirstDialogForm fdf = new FirstDialogForm();
//Show the dialog
fdf.ShowDialog();
}
else
{
//Not first time of running application.
}
}
Note: wrote this from my phone, so I couldn't compile to test
Edit: Checked code and added image from desktop.
You can have bool value in your settings file which is a "user setting" which means you can change it to true save it for this specific user.
When your application starts just check that value. If it's false show your dialog and change it to true and it will stay true.
public void Form_Load(object sender, EventArgs e)
{
if(Settings.Default.ShowDialog)
{
Settings.Default.ShowDialog = false;
Settings.Default.Save();
// show first disalog
}
// rest of code if needed
}
Here's an MSDN link on user settings:
http://msdn.microsoft.com/en-us/library/bb397750(v=vs.110).aspx
Ok, so I assume you're creating WinForms application. First of all, locate the Load event in your main Form event lists (or simply double click your Form in Designer panel). The following method stub will pop up:
public void Form1_Load(object sender, EventArgs e)
{
}
And modify it like this:
public void Form1_Load(object sender, EventArgs e)
{
MessageBox.Show("Your message here");
}
I have a folderBrowserDialog control and i have a button named click
i did like this way
private void click_Click(object sender, EventArgs e)
{
folderBrowserDialog1.ShowDialog();
}
If what you wish to accomplish is to automatically display a folder of your choice whenever the FolderBrowserDialog is shown, then you can use the following code:
private void click_Click(object sender, EventArgs e)
{
FolderBrowserDialog f = new FolderBrowserDialog();
f.Description = "Please browse to, and select a folder";
f.RootFolder = #"C:\Name Of Folder You Want Displayed\";
using(f)
{
if(f.ShowDialog() == DialogResult.OK)
{
// Do something when the user clicks OK or Open.
}
}
}
Or, you could simply add a FolderBrowserDialog to your Form from the Visual Studio ToolBox and click on the Properties tab, and then click the down arrow to the right-hand side of the 'Root Folder' option and select one of the listed folders from the drop-down menu.
Hope this helps.
You can use a custom build Folder Browser Dialog/Control for this. Try this: http://www.codeproject.com/KB/miscctrl/FileBrowser.aspx