|
BoneSoft wrote: Just give them any name if it just goes by order?
Correct, as long as the names are unique, only order matters. Since the names are still keys in the collection, they need to be unique or you get the unexpected side effect of redefining a parameter...
Kinda sucks, but I guess it's a compatibility thing...
|
|
|
|
|
Maybe because I used too many controls,my application has the phenomenon of flicker.I used SetStyle function like this:
this.SetStyle(
ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.DoubleBuffer, true);
but it seems no use. how can I avoid it?
|
|
|
|
|
according to the documentation you should call UpdateStyles()
after setting the style bits
Luc Pattyn
|
|
|
|
|
I have tried according your advice,but it is no use just as before,my code like the following ,is it right?Maybe I should write it in another way.
public FormRecite()
{
InitializeComponent();
this.SetStyle(
ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.DoubleBuffer, true);
this.UpdateStyles();
mainFormRecite=this;
this.sqlConnection1.Close();
}
|
|
|
|
|
You've said your Form has a huge number of controls on it. Maybe you should do double buffer on the controls too.
|
|
|
|
|
Hi,
In my applications, I usually use LPW_DoubleBufferedPanel instances, where
LPW_DoubleBufferedPanel simply inherits from Panel, while setting the three
style bits in its constructor (the SetStyle method is protected, so you can not
call it from outside the panels).
using System;
using System.Windows.Forms;
namespace LP_Basics {
//################################################################################
///
/// LPW_DoubleBufferedPanel is a panel that uses double buffering to avoid flicker.
///
//################################################################################
[System.ComponentModel.DesignerCategory("Code")]
public class LP_DoubleBufferedPanel : Panel {
///
/// Construct a double buffered Panel.
///
public LP_DoubleBufferedPanel() {
// set 3 bits to get double buffering
SetStyle(System.Windows.Forms.ControlStyles.DoubleBuffer,true);
SetStyle(System.Windows.Forms.ControlStyles.AllPaintingInWmPaint,true);
SetStyle(System.Windows.Forms.ControlStyles.UserPaint,true);
}
}
}
(remark: I don't need the UpdateStyles method here since the Panel's handle has not
been created yet, so the panel is born with the new style settings).
Following your mail, I have tried SetStyles on a form, and it does not work the way you and I would hope. It seems the double buffering characteristic is not inherited by
its children.
So I suggest you start using LPW_DoubleBufferedPanel and the like.
I admit, if you need a lot of different kinds of Controls, this may become cumbersome.
Luc Pattyn
|
|
|
|
|
hi every one
well I'm having a bit of trouble in setting the bacground color of the windows Form I'm trying to make here. I wanna give it a customized color which is from the picture of a form built previously but it doesnt gove any option to make your own color uknow like the way we make a color if we dont find any availabe color appropriate.
thanks in advance...
|
|
|
|
|
This should work out:
_form.BackColor = Color.FromArgb(1,2,3);
-Larantz-
|
|
|
|
|
thanks alot man I really appreciate this.
|
|
|
|
|
You can also just type in the RGB ints seperated by commas in the background property field. You're not required to use the GUI dialog.
|
|
|
|
|
Hi,
I have a user control B put inside the parent user control A.
On the child control B, I have put a combo box and a BindingSource BS1. In
the load event of child control B, I fetch the
values from the database and put in a generic BindingList of NameValueClass.
(given below)
class NameValueClass
{
private int _id;
public int Id
{
get{return _id;}
set{_id = value;}
}
private string _name;
public int Id
{
get{return _name;}
set{_name = value;}
}
}
BindingList<namevalueclass> list = RetrieveComboValuesFromDataBase();
Next I assign the list to datasource of BindingSource BS1 (given below)
BS1.DataSource = list;
combo.DataSource = BS1;
combo.DataMember = "Name";
combo.ValueMember = "Id" ;
I have put a Grid on Parent control A. Now I want to show some detail data
on grid, On changing the combo box value i.e. As soon as the
value in the combo box is changed, I need to fetch corresponding details
from database and display on grid. What is the best
way to achieve the same using the BindingSource.
Regards,
Rajat.
|
|
|
|
|
Not sure where to ask this question, so I will start here since I am using C#.
I finally got an upgrade to Visual Studio 2005. I converted one of my projects over and cleaned up a few things that VS2005 was complaining about. However, not I can not connect to the SQL server database. If I compile the application with VS2003, the connection works fine. But on VS2005 the connection times out on open.
Is there anything different about the SqlConnection object between VS2003 and VS2005?
The connection string is a standard:
Server=...;User ID=...;Password=...;Database=...
(Of course where the ... is filled in with the appropriate data).
It seems to work when the database is on the local computer. I just can't connect to a remote computer...
-- modified at 13:56 Friday 27th October, 2006
|
|
|
|
|
What things did you clean up exactly? Did you move the connection string to a different place in the app config and change the code retrieving the connection string?
|
|
|
|
|
Nothing changed around the SQL connection code. Really only 2 things change: 1) had some classes that needed to override Dispose(). I guess they added Dispose() to the base class. 2) Had to change from .Handle to using the safe handle stuff.
The odd thing is that the connection string works when the application is run on the machine with the database. It just won't connect over the network. And that is using the exact same connection string with the Server name specified.
Right now the connection string is hardcoded. Later on it will be stored in the registry.
|
|
|
|
|
This just sounds odd. I'm assuming that the 1.1 code works on a remote machine but the 2.0 code does not. Which rules out the possibility that there's a problem with the network setup. But the 2.0 code works on a local SQL server. If it works locally and not remotely, then the first thing to check is that the network and firewall are all set up correctly.
Faced with the problems you have, I would try to reduce everything to the least common denominator. Create a small console app that just runs simple code like this:
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
Console.WriteLine("ServerVersion: {0}", connection.ServerVersion);
Console.WriteLine("State: {0}", connection.State);
}
Then just run it both locally and remotely for 1.1 and 2.0. Then I'd add little pieces from the SQL connection code of your app until I found what broke.
I'm not sure that any of this is helping, but good luck.
|
|
|
|
|
I'm starting to wonder if the Visual Studio 2005 install is bad. This is really weird.
I made the small console app you suggested and ran it on the local machine with the database. Here are the results for the 2003 and 2005 version:
C:\>"test sql 2003"<br />
ServerVersion: 08.00.0194<br />
State: Open<br />
<br />
C:\>"test sql 2005"<br />
ServerVersion: 08.00.0194<br />
State: Open
Then I ran it on a remote machine and got:
C:\>"test sql 2003"<br />
ServerVersion: 08.00.0194<br />
State: Open<br />
<br />
C:\>"test sql 2005"<br />
<br />
Unhandled Exception: System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.<br />
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)<br />
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)<br />
at System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj, UInt32 error)<br />
at System.Data.SqlClient.TdsParserStateObject.ReadSni(DbAsyncResult asyncResult, TdsParserStateObject stateObj)<br />
at System.Data.SqlClient.TdsParserStateObject.ReadPacket(Int32 bytesExpected)<br />
<br />
at System.Data.SqlClient.TdsParser.ConsumePreLoginHandshake(Boolean encrypt, Boolean trustServerCert, Boolean& marsCapable)<br />
at System.Data.SqlClient.TdsParser.Connect(Boolean& useFailoverPartner, Boolean& failoverDemandDone, String host, String failoverPartner, String protocol, SqlInternalConnectionTds connHandler, Int64 timerExpire, Boolean encrypt, Boolean<br />
trustServerCert, Boolean integratedSecurity, SqlConnection owningObject, Boolean<br />
aliasLookup)<br />
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)<br />
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)<br />
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)<br />
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)<br />
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owning Object)<br />
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)<br />
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)<br />
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)<br />
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)<br />
at System.Data.SqlClient.SqlConnection.Open()<br />
at Test_SQL.Program.Main(String[] args)
I have tried increasing the timeout, but it doesn't help and I should not have to wait 60 seconds for a connection to the database on a local network.
Thanks for the help so far, any ideas of where to go from here?
|
|
|
|
|
Well, just for grins, try using integrated security instead of a sql identity. I doubt it will make a difference. The connection string would look like this: Server=(local);Database=Northwind;Integrated Security=SSPI
|
|
|
|
|
After reading some other forums on this, there are other people complaining about the exact same thing and the typical response is to increase the timeout. You could set it to something obscene like 5 minutes and see if it eventually connects. I suspect it's not the network, so maybe you could try an OLE or ODBC connection to see if anything is working at all.
|
|
|
|
|
That actually worked. Thanks.
The odd thing is that it seems to connect in less than 30 seconds, which was the old timeout value. I set the timeout to 600 seconds. After the first connection, it connects immediately. I guess I will need to connect to the database while the program is initializing to hide the long connect time from the user.
|
|
|
|
|
Weird. Well, I'm glad it works. I guess the good part is that you can open a connection in another thread while you're initializing and .Net will keep a connection pool open for you while your program's still open even if you close the SqlConnection.
|
|
|
|
|
Are you using SQL Server 2005? If so, I believe only the local protocols (named pipe, shared mem) are enabled by default (unlike SQL 2000 where TCP is enabled as well). You may have to enable the desired transport protocol (and possibly unblock it in your firewall) to connect remotely.
|
|
|
|
|
Hey ppl,
What's the best way to get an IntPtr representing my object?
The following works, but I don't know if that's the fashionable way to do it:
IntPtr pObject= Marshal.AllocHGlobal(Marshal.SizeOf(myObject));
Marshal.StructureToPtr(myObject, pObject, true); Also, AFAIK, the StructureToPtr() function copies the data to the new allocated memory, which consumes time.
Is there a better way?
Thanks in advance,
Shy.
|
|
|
|
|
Not by spamming the message bord, for sure.
---
b { font-weight: normal; }
|
|
|
|
|
lol... Sorry everyone...
I pushed the "Post Message" button, and got an error...
So I pushed it again, and again...
BTW... Is anybody else experiencing problem with the site except me (not like the one above)?
|
|
|
|
|
shyagam wrote: BTW... Is anybody else experiencing problem with the site except me (not like the one above)?
Yes that happens from time to time. Some days are worse than others.
shyagam wrote: Is there a better way?
Better how?
led mike
|
|
|
|