|
At general to customize the drawing of control you drive your class from it and override OnPaint but not al controls easy for customization like others to look at code do what you want look at Tile a Bitmap Into a TextBox Background[^] it is in VB6 but you can get some ideas from it
MCAD
|
|
|
|
|
I am sorry but i am posting this again because I didn't get reply for my problem if any one can help me please.
I want to pass parameters to crystal reports but i dont know how i found example on microsoft site
// Declare variables needed to pass the parameters
// to the viewer control.
ParameterFields paramFields = new ParameterFields ();
ParameterField paramField = new ParameterField ();
ParameterDiscreteValue discreteVal = new ParameterDiscreteValue ();
ParameterRangeValue rangeVal = new ParameterRangeValue ();
// The first parameter is a discrete parameter with multiple values.
// Set the name of the parameter field, this must match a
// parameter in the report.
paramField.ParameterFieldName = "Customer Name";
// Set the first discrete value and pass it to the parameter.
discreteVal.Value = "AIC Childrens";
paramField.CurrentValues.Add (discreteVal);
// Set the second discrete value and pass it to the parameter.
// The discreteVal variable is set to new so the previous settings
// will not be overwritten.
discreteVal = new ParameterDiscreteValue ();
discreteVal.Value = "Aruba Sport";
paramField.CurrentValues.Add (discreteVal);
// Add the parameter to the parameter fields collection.
paramFields.Add (paramField);
// The second parameter is a range value. The paramField variable
// is set to new so the previous settings will not be overwritten.
paramField = new ParameterField ();
// Set the name of the parameter field, this must match a
// parameter in the report.
paramField.ParameterFieldName = "Customer ID";
// Set the start and end values of the range and pass it to the
// parameter.
rangeVal.StartValue = 42;
rangeVal.EndValue = 72;
paramField.CurrentValues.Add (rangeVal);
// Add the second parameter to the parameter fields collection.
paramFields.Add (paramField);
// Set the parameter fields collection into the viewer control.
crystalReportViewer1.ParameterFieldInfo = paramFields;
Problem is that when i write this code for my reports in c#
I am not finding
"paramField.ParameterFieldName"
in intellisence. I am seeing some other methods but they gives error. I am using V.S. 2003 and crystal report 9.0
Please can any one tell me why its happening
I would be obliged.
Naveed Kamboh
|
|
|
|
|
I haven't been at CP for a while. Hi everyone.
Naveed, if you search through previous post I bet this question was answer multiple times.
I quickly pulled up a file using Google desktop search and I found a function that I used on a previous project. Take a look at this. It might help you:
private void SetParameter(string name, string val)
{
ParameterFieldDefinitions paramFlds = report.DataDefinition.ParameterFields;
ParameterFieldDefinition paramFld = paramFlds[name];
ParameterDiscreteValue discreteValue = new ParameterDiscreteValue();
ParameterValues paramValues = paramFld.CurrentValues;
paramValues.Clear();
discreteValue.Value = val;
paramValues.Add(discreteValue);
paramFld.ApplyCurrentValues(paramValues);
}
Alex Korchemniy
|
|
|
|
|
how to use java script in my asp.net page Anurag Verma 18:06 23 Sep '05
Dear....
I want to use some validations for my forms in asp.net and i want to use java script.Please help me out and tell methe way how to use it
|
|
|
|
|
There are many ways you can use Javascript in your asp.net
ASP.Net come with some validation of controls did you looked to them if no one of them have what you need you can use CustomValidator control and write your javascript
for validating the control for example look at
Allowing Only Numbers in ASP. NET TextBoxes[^]
If You want to call JavaScript code when you click Button for example you can write somthing like
Button1.Attributes.Add("onClick","DoIt();");
this allowed DoIt script function to be called when the user click the Button or write the code directly like Button1.Attributes.Add("onClick","alert('Test Test');");
MCAD
-- modified at 21:30 Friday 23rd September, 2005
|
|
|
|
|
[rant]I've only been at it for about an hour and already don't like it! I'm a long c++ programmer, MFC -- MS-Windows. All I want is a form with an edit box where you can type in a filename and a button that will let you browse for the filename. In C++ I would simply use VC++ 6.0 to create an MFC project, create and initialize an object of type OPENFILENAME, then call the win32 api function. Simple. Without knowing better, using Visual Studio .NET 2003 I created a windows C# project, made the form like I wanted (that was pretty intuitive) then clicked the button on the form to get the event handler. There, everything goes to hell in a handbag. The compiler knows nothing about OPENFILENAME structure. So I downloaded the sample C# tutorial project from codeproject. I can't believe the kind of hell C# programmers have to go through just to do one simple call to a Win32 api function. Its enough to make me throw in the towel and use C++ instead.[/rant]
Isn't there an easier way to accomplish this?
-- modified at 17:34 Friday 23rd September, 2005
|
|
|
|
|
There most certainly is an easier way to do it and it's approximately 1700 times faster. If you ask nicely, I might even tell you about it
|
|
|
|
|
Pretty-please I suppose I probably should buy a book about C#.:->
|
|
|
|
|
See the other reply. You won't learn about a new language and framework in an hour. Believe me, from experience, C#/.NET is ten times faster/easier to use than the corresponding Win32 API (with or without MFC) in 99% of the cases. You'll just have to search for the appropiate classes to do your job.
One thing .NET is a thousand times better is that it has been designed from the ground up, so all the classess are very consistent with each other, whether you are developing a Windows or a web app.
Take your time to learn this new technology, and I'll bet anything you won't want to go back! :->
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
To Browse for files use OpenFileDialog you will find it in the toolbox after that ypu can write some thing like
openFileDialog1.InitialDirectory = "c:\\" ;
openFileDialog1.Filter = "CSharp files (*.cs)|*.cs" ;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
}
For More info look at <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsopenfiledialogclasstopic.asp" rel="nofollow">OpenFileDialog Class</a>[<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsopenfiledialogclasstopic.asp" target="_blank" rel="nofollow" title="New Window">^</a>]
If you really missed Windows API Function that you did not find counterpart in .Net You can use it By using P/Invoke which let you call function in traditional dll
look for Using P/Invoke to Access Win32 APIs[^]
MCAD
|
|
|
|
|
I need to do some cleanup when my dialog closes. I tried overriding mydialog.Close() doing the cleanup there and then calling base.Close(). When the user exits it using the close button everything works as intended, but the X doesn't call Close() and leaves my app in a messedup state.
|
|
|
|
|
The Windows recive WM_SYSCOMMAND Notification when you close minimize or maximize the window or you choose any command from the system menu
So overrid your form WndProc function and handle it
const int WM_SYSCOMMAND = 0x0112;
const int SC_CLOSE = 0xF060;
protected override void WndProc(ref Message m)
{
if(m.Msg==WM_SYSCOMMAND)
{
if(m.WParam.ToInt32()==SC_CLOSE)
{
MessageBox.Show("Application will be close");
base.WndProc(ref m);
}
}
else
{
base.WndProc (ref m);
}
}
if you don not handle other Message you can write it like
protected override void WndProc(ref Message m)
{
if(m.Msg==WM_SYSCOMMAND)
{
if(m.WParam.ToInt32()==SC_CLOSE)
{
MessageBox.Show("Application will be close");
}
}
base.WndProc (ref m);
}
for more information look at WM_SYSCOMMAND Notification[^]
MCAD
-- modified at 18:53 Friday 23rd September, 2005
|
|
|
|
|
You should handle the Closing event of System.Windows.Forms.Form . This event is fired regardless of whether the dialog was closed via the system menu or a close button on your form.
Regards,
mav
|
|
|
|
|
*blush*
In my defense I can only say Friday 4pm.
|
|
|
|
|
|
Real-time event notifications don't work very good over a WAN connection. I found that I had to buffer them and get an update pack about every 15 seconds to get it to work correctly. The VBScript code I used went something like this:
Set objWMIServices=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & machineName & "\root\CIMV2")
set objSink = WScript.CreateObject("WbemScripting.SWbemSink","SINK_")
WScript.Echo "Starting Listeners... Win32_Process"
objWMIServices.ExecNotificationQueryAsync objSink, "SELECT * FROM __InstanceCreationEvent WITHIN 60 WHERE TargetInstance ISA 'Win32_Process'"
Sub SINK_OnObjectReady(wmiObject, wmiAsyncContext)
Set objTargetInstance = objWMIServices.Get(wmiObject.Properties_("TargetInstance").Value.Path_.Path)
WScript.Echo Now() & " - " & objTargetInstance.GetObjectText_()
WScript.Echo objTargetInstance.CreationClassName
If objTargetInstance.CreationClassName = "Win32_Process" Then
Rtn = objTargetInstance.GetOwner(strNameOfUser, strDomain)
If Rtn <> 0 Then
Wscript.Echo "Could not get owner info for process " & objTargetInstance.Name & VBNewLine & "Error = " & Rtn
Else
Wscript.Echo "Process launched by " & strDomain & "\" & strNameOfUser & "."
End If
End If
End Sub
This code is part of a "quick little tool" that watches for new processes to launch and notifies me whenever it happens. I was looking for a certain someone to start gambling on company time and I needed to catch him with his hand in the cookie jar, so to speak.
The "WITHIN 60" clause just means I get an update from the remote machine every 60 seconds instead of right when the event happens. Over a slow connection, real time events tends to get dropped if they happen in quick succession. This was the work around to get more reliable notifications.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for the response.
But when I tried to run the same service on the remote host. I get "User credentials cannot be used for local connections" error. I am sure the loginid which I am using got 'Administrator' privileges.
In my case, I need to montitor the remote host event log and track the error from certain source (which is from config xml) and on certain conditions (which are from config xml). If that happens I restart (via ManagementClass.InvokeMethod) the affected application.
The programmer's national anthem is 'AAAAAAAARRRRGHHHHH!!'. This signature was created by "Code Project Quoter".
|
|
|
|
|
To all those SharePoint Gurus, tell me if this is possible.
I want to customize SharePoint's existing front-end site, and using the SharePoint database in the back end.
My prefered language would be C#. But before I head any further on this, is this feasible?
Stanley
|
|
|
|
|
I have a contextmenu that is called when you press a button. The contextmenu is associated with a single treeview. however, there are other treeviews on the form. When the user clicks on a different treeview and hits the button that calls the contextmenu for the previous treeview, it gives me an error. i expect this. Nevertheless, I need to fix it. How can I get the contextmenu to show only when the user has selected the designated treeview? Thanks.
D
|
|
|
|
|
I'm not understanding your problem. What error are you getting?
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Cops & Robbers
Judah Himango
|
|
|
|
|
This is the error I am receiving: Object reference not set to an instance of an object.
I know why I am receiving this error. I just dont know how to fix it. The contextmenu is designated for only one treeview. When you select on another treeview, and then hit the contextmenu BUTTON, you get this error. Now, keep in mind, if the user knows what they are doing, this should never happen. Nevertheless, I still have to prevent it.
|
|
|
|
|
Run your app in the debugger in VS (Hit F5), you'll see that one of your objects is null, thus throwing an exception.
|
|
|
|
|
How can I list all the databases that are available with sql server 2000.
|
|
|
|
|
SqlServer have sp_databases Stored Procedure which list databases available in the server instance you can write somthing like
private void ListDatabases_Click(object sender, System.EventArgs e)
{
using(SqlConnection cn=new SqlConnection("Server=localhost;Initial Catalog=master;Integrated Security=SSPI;"))
{
cn.Open();
SqlCommand cmd=new SqlCommand("sp_databases",cn);
cmd.CommandType=CommandType.StoredProcedure;
SqlDataReader dr=cmd.ExecuteReader();
while(dr.Read())
{
Debug.WriteLine(dr.GetString(0));
}
dr.Close();
cmd.Dispose();
}
}
MCAD
-- modified at 21:43 Friday 23rd September, 2005
|
|
|
|
|
Fantastic!! I will give this a go and see how it works!
Much Appreciated.
|
|
|
|