|
I use either POHs method, have the callback populate a structure that has onpropertychage to notify the UI. Or if the caller is not the UI I send out a message, this happens when I start an application and all the static data is loaded rather than fire off multiple calls to the service I chain them using the message sink initiate the next service call.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
You can't, and if you think about it you'll see why: the whole purpose of asynchronous programming is that the request returns before it completes, so you can't have the result of running the method. You have two options:
i) call the method synchronously, or
ii) accept that you won't have the result, populate a member variable in the callback and have any downstream code that might read it check whether it's initialised. (If it's not, you can either abort the process or re-queue it, possibly with a delay, depending on what you are trying to do and which is appropriate.)
|
|
|
|
|
Hi I've created a windows app for a user to manage company info. I have a main form with fields(textboxes, datagrids, dates, comboboxes etc) to be completed for new companies. For any existing companies I'd like to add a search box to my main form and I suppose on the click event of a Search button I'd like to prefill the form with all the relevant data. Can anyone point in the direction to any tutorials, links that show me how to do this? I'm relatively new to C# and this is my first project using an EDM.
Thanks for your help
|
|
|
|
|
Hi All,
Trying to get an Input box in C#, (it was asked for!/demanded) I have in the past used
SN = Microsoft.VisualBasic.Interaction.InputBox("Enter Serial Number", "", "", 200, 150);
with the definition
using Microsoft.VisualBasic;
I get the below error:
I'm sure of it but now get Error The type or namespace name 'Interaction' does not exist in the namespace 'Microsoft.VisualBasic' (are you missing an assembly reference?)
What am I doing wrong?
Glenn
|
|
|
|
|
As the message says, you appear to be missing the reference to the assembly that contains this class. Check the references section of your project (in Solution explorer) and add the necessary item.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
If it helps, the required dll is here on my machine:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.VisualBasic.dll
|
|
|
|
|
If you don't want to use the VB-originated InputBoxes, and/or want a slightly different functionality, you can easily roll your own. That is what I did, with a base class, and some derived ones for different kinds of return types and validation rules.
|
|
|
|
|
|
To all who replied (mostly after I chucked coding for the day!!) I have now solved the issue Thank You! The method I had used didn't work this time due to a PC rebuild moving every thing!
Thanks again
Glenn
|
|
|
|
|
I have a DataGridView with three columns (checkbox, text, int). The text and int columns are bound to data from a data source. I want to manipulate in c#, which of the checkbox rows should be checked. I have the below code, however setting the value of the checkbox to true isn't displaying the required checkboxes as checked. Does anyone know how I could implement this?
…
dgvMultiCodes.AutoGenerateColumns = false;
dgvMultiCodes.DataSource = oCodeList.Table;
string SQLState = ChcekedSQLStatement();
SortedList<int, string> slCodeList = new SortedList<int, string>();
int codeCD = 0;
string desc = "";
oCodeList.GoTop();
while (!oCodeList.EoF)
{
codeCD = oCodeList.GetInteger("CD");
desc = oCodeList.GetString("DEF");
slCodeList.Add(codeCD, desc);
oCodeList.Skip();
}
bool bChecked = false;
##DataReader checkedList = new ##DataReader(SQLState, currentUser.oConnection);
while (checkedList.Read())
{
bChecked = slCodeList.ContainsKey(checkedList.GetInteger("KEYCODE"));
if (bChecked)
{
foreach (DataGridViewRow row in dgvMultiCodes.Rows)
{
if (row.Cells[dgvCodeCol.Index].Value.ToString() == checkedList.GetString("KEYCODE"))
{
row.Cells[dgvCheckCol.Index].Value = true;
break;
}
}
}
bChecked = false;
}
…
|
|
|
|
|
Maybe the code I provided was a little long winded. The line of code that isn't displaying the checkbox as checked is...
row.Cells[dgvCheckCol.Index].Value = true;
Is there some other property of the checkbox cell that I need to set or do I need to refresh the cell for the checkbox to appear checked?
Thank you
|
|
|
|
|
Hello Every one,
how can i insert duplicate value in HashSet
|
|
|
|
|
You can't, by definition: The HashSet<(Of <(T>)>) class provides high performance set operations. A set is a collection that contains no duplicate elements, and whose elements are in no particular order.
|
|
|
|
|
You can't. Would the negative of the value work for you?
Or use a Dictionary with a count of how many of the item you have.
Or a Dictionary with a List of the duplicate items.
modified 5-Mar-12 8:20am.
|
|
|
|
|
If you must insert duplicates, then you are using the wrong type. Use a type that allows duplicates, a List<t> for example.
|
|
|
|
|
|
Hi,
You can use the HashSet as:
Hashset(Key(Type1), Value (List(Type2)))
Dictionary<string, List<object>> dicElements;
|
|
|
|
|
In datagridview filterpoup tool, combobox for dropdown shows distinct values of the table not gridview. So the combobox some times shows the value not in filtered gridview. For example .
I already removed all the records from datagridview the catagory column 'C' . So no more record in datagridview but when I popup combobox filter , that catagory 'C' still is there . So anybody can advice me how I refresh the combox item after filtering the datagridview.
With thanks
Pol
public void RefreshValues() {
if (!(this.DataGridViewColumn is DataGridViewComboBoxColumn)) {
DataTable DistinctDataTable = this.BoundDataView.ToTable(true, new string[] { this.DataGridViewColumn.DataPropertyName });
DistinctDataTable.DefaultView.Sort = this.DataGridViewColumn.DataPropertyName;
comboBoxValue.DataSource = DistinctDataTable;
}
|
|
|
|
|
Hi everybody,
How can i execute multiple dos commands on a c# function?
Here are my 3 commands to be executed:
"cmd.exe"
"cd c:\"
"TF get $Project_Path"
Last commands is for Team Foundation Server(TFS) to get latest operation for a project.
I've tried to do this operation with the below code but it did not work. Where is the error and how can i do it, run the 2 commands at the same time??
strCmdText1 = @" cd C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE";
strCmdText2 = @"TF get $/Project_Path /recursive";
System.Diagnostics.Process.Start("CMD.exe", strCmdText1);
System.Diagnostics.Process.Start("CMD.exe", strCmdText2);
|
|
|
|
|
Create a batch file containing all the commands and execute that file. What you have done above is to try and execute two totally independent commands, so it probably fails.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
You should just be able to run "TF" (TF.exe?) with parameters "get $/Project_Path /recursive" in the working directory you want to run it in.
|
|
|
|
|
Hi i want to insert the new XML tag in the existing file.
How can we insert the tag after a particular node using C#4.0
thanks
Harish
|
|
|
|
|
You can use the XmlNode.InsertAfter[^] method to insert new nodes into an xml document.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
HI THIS IS MY C# PROGRAM I WANT TO GET A BOOLEAN RESULT TRUE OF FALSE I DIDNT FIND ANY ERROR....BUT THE PROB IS ONLY THE EXECPTION PART IS GETTING EXECUTED...ITS A LOGIN PAGE,....
public bool validateuser(User u)
{
bool result = true;
try
{
string validateq = "select count(*) from register where user.username = @username and user.password = @passwd ";
cmd = new SqlCommand(validateq, con);
cmd.Parameters.AddWithValue("@username", u.username);
cmd.Parameters.AddWithValue("@passwd", u.password);
con.Open();
reader = cmd.ExecuteReader();
reader.Read();
int r = Convert.ToInt32(reader[0]);
if (r > 0)
{
result = true;
}
else
{
result = false;
}
return result;
}
catch (Exception ex)
{
result = false;
return result;
}
}
|
|
|
|
|
User is a reserved word, it must be escaped:
...where [user].username = @username and [user].password = @passwd
Do not forget to close your reader, a good place for that is in a finally clause:
try
{
}
catch(Exception ex)
{
}
finally
{
if (reader!=null)
reader.Close()
}
|
|
|
|