|
I have made a UserControl for designing WYSIWYG tables for printing.
The user control has a DataGridView control which is visible through the myUserControl.Grid property
Passing the new DataGridControl works fine (myUserControl.grid = newDataGrid; ), except that the UserConrol's DataGridView is not visually updated/refreshed.
My question is, how can I pass a DataGridView to the UserControl and make it repaint/refresh/update to show the new instance of the DataGridView control?
I'm not using any data binding, and I have tried all the .Update() and Refresh() mehods available (I think).
Thanks,
Marius
|
|
|
|
|
Hi. I need to do this:
AnotherClass.Cmd() //does a Process.Start() which takes 30 secs to complete
while(AnotherClass.Cmd().Thread.IsAlive) { this.label.text=i.tostring(); i++}
DoThat()
I tried many things with normal threads and asnyc calls but I couldn't manage to do it without locking the main thread(so label/form is not refreshed) or go to DoThat() without completing Cmd()
Any ideas are appreciated
|
|
|
|
|
What problem are you experiencing? It's hard to tell... Exceptions? Not updating? Need more info.
Scott P
"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand
|
|
|
|
|
Are you trying to prevent the UI from blocking until AnotherClass.Cmd() completes? If that's the case, you can use http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx[^] to push the time consuming call to another thread. Something like
BackgroundWorker bgWorker = new BackgroundWorker();
bgWorker.DoWork += new DoWorkEventHandler(
delegate(object sender, DoWorkEventArgs e) { AnotherClass.Cmd(); });
bgWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(
delegate(object sender, RunWorkerCompletedEventArgs e) { DoThat(); });
bgWorker.RunWorkerAsync();
Does that help?
|
|
|
|
|
S. Senthil Kumar wrote: Are you trying to prevent the UI from blocking until AnotherClass.Cmd() completes?
Yes and no. I need to display some values(constanly changed) using label and while Cmd() runs and when it's completed resume the normal workflow. I'll check BackgroundWorker, thanks.
|
|
|
|
|
Sorry if I am asking DB question in the wrong message board
hi friends
I tried to run the script db.sql using SQLCMD.I tried to execute it with the following command....SQLCMD -E -i C:\a\db.sql.
It is not working in my system.It is showing the error "Could not open connection to SQLSERVER [2]"..."login timeout expired"....But this command is working fine in other system.Would you help me to trouble shoot this problem
With regards
Denver
Reply·Em
|
|
|
|
|
Hi,
I am loading a dll say XYZ.dll dynamically from console application by using activator.createinstance() method. This XYZ.dll is having reference to a data access layer ABC.dll which has reference to the 3 MS-DAAB dlls of enterprise library:
1. Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings
2. Microsoft.Practices.EnterpriseLibrary.Data
3. Microsoft.Practices.ObjectBuilder
I have placed these 3 dlls and ABC.dll in the folder with the exe of console application. However XYZ.dll is not placed there as it will be loaded at runtime specifying a certain path. Now when I try using code which uses the MS DAAB dlls then I am getting an error:
Unable to cast object of type 'Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings' to type 'Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings'
(I do not get this error when I am not dynalically loading the dll)
Note: I have specified the dataConfiguration section in App.config of Console Application.
Any help is appreciated.
Pankaj Chamria,
Software Programmer.
|
|
|
|
|
I am trying to add a AD user to a local group, but keep on getting an exception:
ex Message - Exception has been thrown by the target of an invocation.
ex InnerException - An invalid directory pathname was passed
<br />
DirectoryEntry activeDirectory = new DirectoryEntry("LDAP://DomainName.com", LoggedOnUser, LoggedOnPassword);<br />
DirectorySearcher dsUsers = new DirectorySearcher(activeDirectory);<br />
<br />
dsUsers.Filter = "samaccountname=" + userName;<br />
<br />
SearchResult srCheckUser;<br />
if ((srCheckUser = dsUsers.FindOne()) != null)<br />
{<br />
DirectoryEntry newUser = srCheckUser.GetDirectoryEntry();<br />
currentGroup.Invoke("Add", new object[] { newUser.Path.ToString() });<br />
}<br />
<code>
|
|
|
|
|
|
Hello..
I want to use the DataGridView only as View, that's why, I don't want to allow user to select any cell.
If user select a cell, it will be marked as "dark blue cell". How to avoid this ?
Are there any properties to disable any selection from user ?
Thx...
|
|
|
|
|
you can set the DefaultCellStyle of a DataGridView, this will allow you to give the appearance of the Cell NOT being selected. like this ...
<br />
DataGridViewCellStyle style = new DataGridViewCellStyle();<br />
style.SelectionBackColor = Color.White;<br />
style.SelectionForeColor = Color.Black;<br />
dataGridView1.DefaultCellStyle = style;<br />
BUT, the easiest would be to use the CellStateChanged event, like this ...
<br />
private void dataGridView1_CellStateChanged(object sender, DataGridViewCellStateChangedEventArgs e)<br />
{<br />
if (e.Cell.Selected)<br />
{<br />
e.Cell.Selected = false;<br />
}<br />
}<br />
<br />
hope it helps
<font color="blue">Csharp</font> me = (<font color="blue">Csharp</font>)Dynamic_Sysop; <font color="#008000">// My Signature.</font><br><font color="#008000">$twins</font> = <font color="#008000">me.twins</font>(<font color="#800080">"Taylor"</font> , <font color="#800080">"Delta"</font>); <font color="#C0C0C0">// My twin daughters.</font><br>echo <font color="#008000">$twins</font>;</br></br>
|
|
|
|
|
I need to write a manager program connect to a remote server to display the status of the server. I have a login form, when i connect successful it will show the main form. In this form I have a lot of buttons (on the left panel), each button when we click will open a new form (on the right panel).
I want to declare and initialize all the variable at the beginning of the program, in Program.cs file and using the varialbes and methods in other forms. See the code Snippet below.
My question is that, when I initialize an instance of AManager in region checkManagerAPI() like above:
_manager = new AManager(host, port, loginame, loginpwd);
When I change to another form, why I can't use the _manager again? How to make it become global access?
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace MainForm
{
static class Program
{
const string host = "10.0.0.2";
const int port = 5000;
const string loginame = "name";
const string loginpwd = "pwd";
.....
public static AManager manager;
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
checkManagerAPI();
Application.Run(new FrmMain());
}
// checkManagerAPI() region is here:
#region checkManagerAPI()
checkManagerAPI();
{
manager = new AsteriskManager(host, port, loginame, loginpwd);
//a lot of code....
}
#end region
}
}
|
|
|
|
|
public static is global. Perhaps you would be better to use delegates, or create a public static class to hold just the data you ant to share ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thank you, I have solved this problem.
|
|
|
|
|
hy everyone!
what happens in cases like this:
string myinput = "12345678910";
myinput = myinput.toString({0:10});
Does this throw an exception or does it cut off all charecters > 10 ??
Because I want the string to be insert no matter if it is too long or not. If it is too long then this should be handled by a warning but the string should be insert without cutting off anything.
So I wonder if this function tries to format it to length 10 but accepts strings which are longer as well, or if it doesn't. Because if it doesn't then i have to take care about this myself by checking, if the string is too long.
Thanks.
Stephan.
|
|
|
|
|
Why write such a long post instead of just trying it to see ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
stephan_007,
What language is this in?, because it doesn't compile in C#.
Regards,
Gareth.
|
|
|
|
|
it's c# but i didn't copy it from my source, i just typed it into here. maybe i misstyped it.
the reason why i posted it here is, maybe someone already did anything similar and could help me to keep it simple
because it looks like i usually solve problems in a too difficult way which could be solved by default functions. that's why.
i know i could try the two statements above in my own code, but as i already said, maybe someone knows a different way to format the string without raising an error
|
|
|
|
|
ups, i misstyped the second line!
it should be
myinput = String.Format("{0,10}", myinput}
and i already found out, it ignores the formating, if the string is longer than defined in the formatsring. so i have to check it myself, by splitting off the relevant position in the format string to compare it to.
modified on Monday, May 5, 2008 9:10 AM
|
|
|
|
|
I believe it will throw an exception..even sql server throws an exception that warns that string data is bieng truncated. your best solution would be to either limit what the user can type in, or check its length before you try to insert it, and either truncate it yourself, or tell the user that the input is invalid(best solution so the user doesnt get bad data in the db or where ever you're putting it)
|
|
|
|
|
the user wants this behaviour:
if the string is smaller or equal the length defined in the format string, then just insert it, if it is longer than the length defined, then the programm should throw a worning, but insert the data anyway.
i have to insert it into a stream. so if it is too long, then all other info is moved x characters to the right (x is the difference to the defined and the real length).
well, because it just ignores the length if it is too long, i have to write a check myself to know, if i have to throw a warning or if the length is ok.
|
|
|
|
|
you should probably try to explain to the user that just inserting the data even if its too long is a bad idea. you could just use the string.Length to find out how long it is, and use Remove to cut off any unwanted characters
|
|
|
|
|
Dear all,
I am building a c# application. I wanted to add to it the capability that i dictate a URL and then write it in a text box, so i searched and i found that i should use class "DictationGrammar". However i couldnot find an intact example or set of steps to follow to build the required utility. I would appreciate it if anyone could help...
Regards,
|
|
|
|
|
Hi All
I Wount to use the workflow project , but i dont know who i can do ...
who can hellp me ?
thank for any body hellp me
Thaer
|
|
|
|
|
Please read the forum guidelines.
|
|
|
|