|
|
Hi all,
well simply after a thread runs, in special situation it(thread) try to refresh a form of my application and an error appeared which says that "you can not change object in other thread ..."
what should i do?
|
|
|
|
|
your description isn't very accurate, however I think this[^] is what you need.
|
|
|
|
|
hi all
i have recently created a new simple control
the problem will came up when we drop it in to the form
because it will set sum unwanted properties in Form1.Designer.cs
i set the Default Value for thees properties
[DefaultValue("89/3/24")]
and also set it in control`s constructor
but the problem still persists
|
|
|
|
|
well,
[defaultValue] is not for setting initialize value for an object, it just change appearance of the property in design time,
[DefaultValue("hello")]
public string txt{get;set}
now in design time when you change the text of this property it would be bold text!
for ur purpose u should define ur property as this:
private string _txt="Hello"; public string txt
{
get
{
return _txt;
}
set
{
_txt=value;
}
}
|
|
|
|
|
i need help on usb drive. when a user inserts a usb drive, auto run starts and diplays some of the options to select from. what i want is to add my applications exe to the list of auto run when usb drive is inserted in usb port, so that i can select my application and do some aftermath. please help. simply i want usb drive to run my application when i insert it into my computer.
|
|
|
|
|
you should pick one forum to ask your question.
|
|
|
|
|
Dear friends
i have developed a windows application the thing i want to do i want to make its demo setup so that i can give it to my clients for a period of time after that application fails to open or reinstallation
i have tried many things but i am fail to make demo
any ideas
thanx in advance
|
|
|
|
|
What part of the process is the actual problem?
|
|
|
|
|
well,
I suggest u to use a hardlock. if so u can store the information of expiration and etc. in it, else u should store those information in a hidden path in a encrypted file
this post is really useful:
Application Trial Maker
good luck
|
|
|
|
|
Greetings,
I grew up learning C and Java, so having just recently taken to C# for a new project, I'm still find my way. Hopefully this isn't a silly question
Basically I wish to build a class that contains configuration info for my application. It needs to hold a port number, a directory/folder name, and 3 arrays: an array of booleans, an array of strings for descriptive names, and an array of integers. I've written get/set methods for the server port number and the array containing the booleans, but Visual Studio 2010 is giving me a compilation error with my get/set methods for the last two arrays. "Type '......' already defines a member called 'this' with the same parameter types". Yet if a try and explicitly set the get/set method for the specific array (without using 'this'), it does not work either.
Here is the code:
namespace Test
{
public class TestConfig
{
private int ServerPort;
private String folderName;
private Boolean[] ChLog = new Boolean[12];
private String[] Label = new String[12];
private int[] CallibrationUnit = new int[12];
public int setServerPort
{
get
{
return ServerPort;
}
set
{
ServerPort = value;
}
}
public Boolean this[int pos]
{
get
{
return ChLog[pos];
}
set
{
ChLog[pos] = value;
}
}
public String this[int pos]
{
get
{
return Label[pos];
}
set
{
Label[pos] = value;
}
}
public int this[int pos]
{
get
{
return CallibrationUnit[pos];
}
set
{
CallibrationUnit[pos] = value;
}
}
}
}
Am I best to avoid using the get/set methods in this case? Or should I use a separate class for each of the arrays I'm trying to set up? (this seems very inefficient to me).
I've searched high and low for an example showing the interection of multiple array variables from within a class, but bizarrely I haven't found anything as complex is what I'm trying to do (and I don't think its that complicated).
Any feedback would be most appreciated.
Benjamin
|
|
|
|
|
Well, the issue here is that "two methods cannot differ in return type only". Here method is indexer (this), but rule is the same. You have three indexers, that only differ in return type, which means, that when you do:
<br />
TestConfig test = new TestConfig();<br />
Console.WriteLine(test[2]);<br />
Compiler will not know, which indexer you want to call, because Console.WriteLine is overriden for string, int and bool. That's why you cannot create indexers like this. You can however create indexer based on other type, for example string. So you can have
<br />
public int this[int pos]<br />
{<br />
}<br />
<br />
public int this[string pos]<br />
{<br />
}<br />
It is possible to do what you want to do, but that would require creation of three additional classes, one for each array you want to store. And indexing would be provided by fields (you have a type StringIndexerTable and field of this type in your TestConfig class).
|
|
|
|
|
Rather than having several arrays running in parallel, you could create a single array holding instances of a new class or struct. Example:
public class Channel {
public Boolean ChLog;
public String Label;
public int CallibrationUnit;
}
public class Test {
private Channel[] channels=new Channel[12];
}
The choice between class and struct is yours; for bigger objects, I would favor class, and also when references come in handy, as in what follows.
Finally, rather than setting an upper limit for the number of channels you can handle, it is often better to use a collection, as in:
public class Test {
private List<Channel> channels=new List<Channel>();
...
channels.Add(new Channel(true, "aha", 3));
Console.WriteLine(channels[3].ToString());
...
}
One advantage of generic lists is they don't need a dimension, as they can grow dynamically.
|
|
|
|
|
Hello,
I work with Active Directory In c#.
how i know when user created ?
Thank You.
|
|
|
|
|
You can use DirectoryEntry to achieve this. Here's a sample piece of code:
public void FindUser(String userName)
{
DirectoryEntry entry = GetDirectoryEntry();
DirectorySearcher search = new DirectorySearcher(entry);
string filter = string.Format("(&(ObjectClass=user)(cn='{0}'))", userName);
search.Filter = filter;
foreach (SearchResult result in search.FindAll())
{
try
{
System.DirectoryServices.DirectoryEntry de = result.GetDirectoryEntry();
Console.WriteLine("WhenCreated : " + de.Properties["WhenCreated"].Value.ToString());
Console.WriteLine("User Name : " + de.Properties["sAMAccountName"].Value.ToString());
}
catch (Exception ex)
{
}
}
}
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
|
Hi Folks,
I'm hoping someone can assist me with a (hopefully) simple question. Is there a way to query a database to get the type of the parameters expected by a stored proc, or the column types of a table. I know this can be done through SQL for most databases (e.g. see below, for SQL Server Column Types), but want a solution which works with any database.
SELECT name
from sys.types
where user_type_id in
(
select user_type_id
from sys.columns
WHERE object_id = OBJECT_ID('@schemaName.@tableName')
and name='@columnName'
)
Background
For anyone wanting to know more about why I'd need this, here's a little more info on what I'm attempting.
I'm writing a web service, which can act as a wrapper to any databases. The databases' connection strings will be included in the config file, using the MS Enterprise Library, so that when a call is made, the name of the DB can be included, which can then be used to get the appropriate connection.
Reading information is pretty simple; given the database name and the table / (parameterless) stored proc name the code reads from that object, and outputs data in the format <tableOrProcName><row><fieldName>...</fieldName>...</row>...</tableOrProcName>.
However, when performing inserts (and other operations where I'd need to be cognizant of data types), I'd like to query the database to get a list of expected parameter/column names and types, which I can then cross reference with the names of the XML 'Field' elements, to convert the values from strings to the correct types before populating the commandText / parameter.
Once coded, I'll make the solution available on here for anyone looking to do the same.
(For anyone wondering why we'd need a wrapper for databases, the answer is many programs these days come with simple methods for attaching to web service calls, but don't provide similar features for databases, so this is a simple & flexible workaround. Security is not an issue, since both the webservice and database are configured to only allow the service account access, so users can't use the service as a backdoor).
Thanks in advance,
JB
modified on Monday, June 14, 2010 7:50 AM
|
|
|
|
|
I get a DataReader* and use its GetSchemaTable method -- it works on all the databases I've used so far.
* I use a query like "SELECT ... FROM ... WHERE 0=1 " so the DataReader doesn't unnecessarily retrieve any data.
|
|
|
|
|
Ahh that's great - thanks for the info. It took me a bit of time to realise that columns were rows in the schema, so I've chucked some sample code below for anyone looking to do something similar:
DbConnection con = new SqlConnection(connectionstring);
DbCommand command = con.CreateCommand();
command.CommandType = CommandType.Text;
command.CommandText = "select * from dbo.DemoTable where 0=1";
command.Connection.Open();
using (IDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection))
{
DataTable table = reader.GetSchemaTable();
foreach(DataRow row in table.Rows)
{
Console.WriteLine(string.Format("{0}: {1}", row.Field<string>("ColumnName"), row.Field<Type>("DataType").ToString()));
}
}
command.Connection.Close();
Console.WriteLine("Done");
Console.ReadKey();
However, this won't work for getting the input parameters for a stored proc. Do you know of an equivelant to the following?
SELECT name
from sys.types
where user_type_id in
(
select user_type_id
from sys.parameters
WHERE object_id = OBJECT_ID('@schema.@storedProc')
and name='@paramName'
)
Thanks again for your help so far; it's very much appreciated.
Kind regards,
JB
|
|
|
|
|
Inverso1 wrote: for getting the input parameters for a stored proc
That would depend on the database; not all of them support them.
|
|
|
|
|
Hello, I am working in visual studio to make a project which requires using lists. I need a little help to complete this. The first thing I need to know is how to select a top result in a list, so that its highlighted, just like when you click. How would I code this so that it works with the down arrow, I know you use keycode etc, but can’t figure out the way to highlight it …. Then when I press enter I want to select the list item… Thanks…
Next, I have two forms and trying to make a “find and replace” function, so this requires looking on a richtextbox in the first form and when a button is clicked on the find and replace form it should effect it. My question is however, how do you connect to another form ? because I have no idea what to do ….
Last question, I need to know a quickly print and print preview a rich text box, thanks for all your help
Steve
|
|
|
|
|
SRJ92 wrote: The first thing I need to know is how to select a top result in a list, so that its highlighted, just like when you click.
Sounds like a ListBox [^]. The link also has a code-example on selecting specific items.
SRJ92 wrote: Then when I press enter I want to select the list item…
I believe that you can do that already using the space-bar, allowing for multiple selections. Perhaps you could replace the "return"-keypress with a space-character?
SRJ92 wrote: My question is however, how do you connect to another form ?
You'd "show" Form2 from Form1 . Information can be passed by creating additional properties in Form2.
SRJ92 wrote: I need to know a quickly print and print preview a rich text box
That's not supported out of the box - you'd either need to program it or find a third-party product to provide that functionality.
I are Troll
|
|
|
|
|
how exactly do i "show" Form 1 to Form 2 ?? Thanks
|
|
|
|
|
By calling the Show[^] method of the form;
Form1 myForm = new Form1();
void Button1_Click(object sender, EventArgs e)
{
myForm.Show(this);
} Although I'd prefer names like "MainForm" and "SearchAndReplaceForm"
I are Troll
|
|
|
|
|
Hi ,
Might be a simple fix, but struggling for a long time.
I have built a new site and configured that in IIS, whenever I login to the server I get the "Connect to" windows login dialog. However on pressing cancel in this dialog, te screen loads without any issues.
Any idea how i can get rid of this?
Ramki
|
|
|
|
|