|
C# does not support Optional parameters..
Need to pass NULL instead.
"If our Mind can, the Program can !!"
|
|
|
|
|
Do you mean how can you add a variable number of parameters?
public void DoSomething(params object[] parameters)
{
foreach (object parameter in parameters)
{
...
}
}
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Create an overload. As long as the function signatures differ in the parameter list (or return type, but not advisable), you can have two functions with the same name.
You end up with something like this:
function Add(object item)
{
...
}
function Add(object item, string name)
{
...
}
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
Hi there,
Can anyone please tell me why I cant disconnect or even get ANY exception out of this code..
private void btnDisconnect_Click(object sender, EventArgs e)
{
try
{
IntPtr m_ConnectedRasHandle;
RASCONN lprasConn = new RASCONN();
m_ConnectedRasHandle = lprasConn.hrasconn;
RAS.RasHangUp(m_ConnectedRasHandle);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Thanx a bunch guyz
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
It's a strong bet that after creating a new RASCONN object, the hrasconn field is probably zero. To hang up a dial-up connection, you'll need to pass the handle you got back from RasDial or from RasEnumConnections .
You don't show the code, but I'd guess that RAS.RasHangUp is an extern function called through P/Invoke. As such, it won't throw an exception - instead, it will be returning an error code.
Style: in most conventions, the m_ prefix should be reserved for member variables and should never be used for a local variable. In the Windows C API, lp indicates a (long) pointer to an object. I would only use this in C# for actual pointer variables, unless in a P/Invoke declaration where I tend to match the original declaration's parameter names.
|
|
|
|
|
Thanks a bunch Mike, but sorry .. I'm kinda new to this RAS thing that I will be very glad if you can show me in brief how can you do it.. I've imported a class called "RAS.cs" from this project and I used this code in a button I just created..
private void btnDisconnect_Click(object sender, EventArgs e)
{
try
{
RASCONN lprasConn = new RASCONN();
lprasConn.hrasconn = IntPtr.Zero;
IntPtr m_ConnectedRasHandle;
m_ConnectedRasHandle = lprasConn.hrasconn;
RasStats stats = new RasStats();
RAS.RasGetConnectionStatistics(lprasConn.hrasconn, stats);
int Minutes = ((stats.dwConnectDuration) / 60);
MessageBox.Show(Minutes.ToString());
RAS.RasHangUp(m_ConnectedRasHandle);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Thanx again for your help Mike
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hi All
I am displaying a listview on or in a panel and I would like to save the listview/panel as a jpeg. I have already done this but my major problem is that it is saving the panel rather than what it is in it.
What is being saved is what is on the screen, scrollbars included.
How do I get it to save that which is not visible on the screen.
James C Mullaney(N Generation Steam)
|
|
|
|
|
Hi,
Do you want the contents of the ListView be saved in a Text File or in some form of image ? If it is the text file, then just iterate through the items and create a string. Use this string to create a new text file.
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
Hi coolestCoder
Thanks for the reply, I want to save the ListView as a JPEG but as a text file would be good as well.
My problem is that I am saving the panel rather than the ListView that it is displaying.
James
|
|
|
|
|
hi
i wanto create an aciveX in C# .
i search in internet but can not find anything .
can you guide me ?
|
|
|
|
|
Right click on Toolbox > Choose items > help yourself
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
|
hi, there is no concept of ActiveX in C#. the workaround for this -- Try this it will work (Register and Unregister)
namespace test{
[GuidAttribute("register with some guid ")]
[ProgId("Any string")]
[ClassInterface(ClassInterfaceType.AutoDual)]
public class ActiveXControl : System.Windows.Forms.UserControl
{
// ur code + constructor + all other stuff
[ComRegisterFunction()]
public static void RegisterClass ( string key )
{
StringBuilder sb = new StringBuilder ( key ) ;
sb.Replace(@"HKEY_CLASSES_ROOT\","") ;
RegistryKey k = Registry.ClassesRoot.OpenSubKey(sb.ToString(),true);
RegistryKey ctrl = k.CreateSubKey ( "Control" ) ;
ctrl.Close ( ) ;
RegistryKey inprocServer32 = k.OpenSubKey ( "InprocServer32" , true ) ;
inprocServer32.SetValue ( "CodeBase" , Assembly.GetExecutingAssembly().CodeBase ) ;
inprocServer32.Close ( ) ;
k.Close ( ) ;
}
[ComUnregisterFunction()]
public static void UnregisterClass ( string key )
{
StringBuilder sb = new StringBuilder ( key ) ;
sb.Replace(@"HKEY_CLASSES_ROOT\","") ;
RegistryKey k = Registry.ClassesRoot.OpenSubKey(sb.ToString(),true);
k.DeleteSubKey ( "Control" , false ) ;
RegistryKey inprocServer32 = k.OpenSubKey ( "InprocServer32" , true ) ;
k.DeleteSubKey ( "CodeBase" , false ) ;
k.Close ( ) ;
}
}
}
|
|
|
|
|
tanks
i am going to test it.
|
|
|
|
|
Hi, I want to create a custom textbox control in ASP.Net using C#, which extends the properties of the normal textbox control and it only allows numeric, alphabetic and alphanumeric characters depending upon the users choice. It should have a built-in client side validation for the same. Also, it should have a property called required, which when set to true, the text box also shows the property of the required field validator.
-----Have A Nice Day-----
|
|
|
|
|
assiduous wrote: Hi, I want to create a custom textbox control in ASP.Net using C#, which extends the properties of the normal textbox control and it only allows numeric, alphabetic and alphanumeric characters depending upon the users choice. It should have a built-in client side validation for the same. Also, it should have a property called required, which when set to true, the text box also shows the property of the required field validator.
-----Have A Nice Day-----
Well good for you. Let us know how you get on with that.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Combine all these and put it to one user control ? Now what problem u r facing ?
|
|
|
|
|
HI CODEPROJECT TEAM.
SOMEONE KNOW HOW INSERT A AUTONUMBER COLUMN IN EXCEL USING OLEDB?.
CONNECTION STRING EXAMPLE:
string cst;
cst="Provider=Microsoft.Jet.OLEDB.4.0;" +<br />
"Data Source=c:\\file.xls;" +<br />
"Extended Properties=\"Excel 8.0;IMEX=1;MaxScanRows=0;" +<br />
"HDR=YES\"";<br />
OleDbConnection conn = new OleDbConnection(cst);<br />
conn.Open();<br />
I NEED DO SOMETHING LIKE:
string SQL;<br />
SQL="ALTER TABLE [sheet1$] ADD [row_id] NUMBER NOT NULL AUTONUMBER";<br />
OleDbCommand cmd = new OleDbCommand(SQL, conn);<br />
cmd.ExecuteNonQuery();
THANKS IN ADVANCED.
SINCERELY.
ANTHONY ACUÑA
PREFERED PHRASE:
SOMEBODY TELL ME WHY IS MORE REAL WHEN I DREAM THAT I AM WAKE?
|
|
|
|
|
Sorry, I cant read CAPS.
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
AFAIK, Excel doesn't support autonumber columns. You'll have to use a database that does, like Access or SQL Server.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
You may have to *fake* an autonumbered column with a formula incrementing the value of the preceding cell.
imho, a person should stay away from anything complex in Excel. The next version may well break all your work -- and impose costs neither you or your clients are prepared to swallow. The more glorious your work, the more costly the *probable* catastrophe.
|
|
|
|
|
I want to compare 2 xml in c#. I have thw two documents loaded into two treeview. I would like to compare them showing the different and new nodes. I want to do something similar to the Source Safe file comparer.
Anyone can help me?
Thanks
|
|
|
|
|
Try to invoke command line and use the "fc" command
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hi all!!
I want to get the data types(int, varchar.. etc) of columns of sql server 2005 database tables, using c#.. pleaseeeee tell me how can i get that.. i've found various code samples but i cant remove the 100's of errors that are produced....
kindly reply if you know the solution...
I'm in deeep deeep sh*t..
|
|
|
|
|
hi,
Use FillSchema method of data adapter to get a data set with one table representing structure of the table returned by the SelectCommand. Then for each column in the Colums collection of the data table contained in the data set you can do whatever you want to do.
Hope the logic is clear.
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|