|
I am writing code that will synch 2 databases. This process can take time and I want the ability cancel the process once it is started. The process is started by the timer when a dialog box is opened. The dialog box has a cancel button, but it doesn't work even if I DoEvents() on the next update of the progress bars. Is there a way to attach a Listner or something that does not require creation of second thread? The biggest issue is that a couple of the database calls can result in blocking while it waits for results. By the way, if this has been answered before sorry, I tried several queries and could have missed the necessary queries. Thanks.
Leo T. Smith
|
|
|
|
|
If you are using 2.0 then simple create a backgroundworker and enable AllowCancel. Have this start rather than the timer when the form is loaded.
If you are not using 2.0, WHY NOT!!!
Seriously, if you can't use 2.0 then you have to do the hard work of creating a thread and stopping the sync. Sorry but creating a seperate thread to run it is the only way to get the functionality while remaining responsive the the UI.
only two letters away from being an asset
|
|
|
|
|
Hi all, using this code I hoped that the phone nuber would show up formatted but it is not for some reason, it still shows unformatted. The numberComboBox is a Winform combo box that is part of a custom control. Everything works well except for the formatting. I also tried "0: (###) ###-####" as the format string but no go! The UnFrmtPhoneNumber member is a string column containing unformatted numbers like 5145555555.
Anyone knows why ?
Thanks for any help
public BindingSource Binding
{
set
{
numberComboBox.DataSource = value;
numberComboBox.DisplayMember = "UnFrmtPhoneNumber";
numberComboBox.ValueMember = "PhoneID";
numberComboBox.FormattingEnabled = true;
numberComboBox.FormatString = "(###) ###-####";
}
}
|
|
|
|
|
That depends on the data type of the phone number. If it's a string, then supplying a FormatString will do nothing because it only works with numeric values, not strings. If the phone number is stored as an Integer, it'll work just fine.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Ok I am working with the 2.0 Framework and I have a Windows Form with 2 DataGridViews. When a Row is Selected in both GridViews and a Toolbar Button pressed I am assigning Data From one to the other and vice-versa. I have the SelectionMode set to FullRow Selection.
Here is where the problem comes into play, if I update without the user moving the selected row in both datagridview controls the update doesnt see that anything has been modified. I have tried calling EndEdit on the GridView, but since the user didnt edit the Cell (I do with code), this doesnt make a difference. Is there a way to force the GridView to post its current changes so the Underlying DataTable thinks its been modified?
Thanks in Advance
Terance Emory
|
|
|
|
|
Ok figured it out in case someone else runs across this problem. I personally dont think there is a way to make a row accept changes without physically moving off the row. So what I did instead is update the underlying DataTable.
This might be a bit of a hack (meaning might be better way to do this), but all I did was pull the key values from the current row using a DataView I locate the DataRow in the DataTable and modify the value there instead of in the cells of the DataGridView. Worked like a charm.
I cant believe something so simple is so hard with this control, give me a method to tell the GridView "Hey Foo, this row is Dirty".
|
|
|
|
|
Hi guys;
I have a question; I am using SQL dataadapter to run a stored procedure of which I am filling the result into a dataset as follows:
DataSet ds=new DataSet();
adp.Fill(ds,"tbACJE");
then I am running the following code:
if(ds.Tables["tbACJE"].Rows.Count>1)
{
What I would like to do from there is to find/compare the sum of 2 columns. i.e CreditColumn and DebitColumn. Could you guys help me on how I could do that please.
Thanks in advance.
sasa
|
|
|
|
|
ds.Tables["tbACJE"].Compute("SUM(Credit + Debit)", "<filter>");
only two letters away from being an asset
|
|
|
|
|
Thanks Mark for your help.
I have another question please on this. After I get the sum; I would like to run and If/else statement where if Sum=0 than do nothing else Pass the Sum of Credit and pass the sum of debit.
By pass I mean
System.Data.DataRow rd= ds.Tables["tbACJE"].Rows[0];
Double fTemp= Double.Parse(rd[0].ToString()); //rd[0] is the Debit Column.
Please help.
sasa
|
|
|
|
|
I am creating a windows application from a pdf. Actually I am bringing a pdf document into a windows form as a background image and adding controls to be able to populate the form from a database. My goal is to be able to print a copy of the populated form and then save it as a pdf. Does anyone have an idea on how I can do this. Print the form or save as a pdf.
Thanks in advance!
|
|
|
|
|
|
I have this for an array of pictureboxes:
GradPic[i].MouseClick += new MouseEventHandler(GradPic_MouseClick);
GradPic[i].MouseDoubleClick += new MouseEventHandler(GradPic_MouseDoubleClick);
private void GradPic_MouseClick(object sender, MouseEventArgs e)
{
this.GradLabel[selectedGradLabel].ForeColor = System.Drawing.Color.Black;
for (int i = 0; i < GradPic.Length; i++)
{
if (GradPic[i] == (PictureBox)sender)
{
selectedGradLabel = i;
this.GradLabel[selectedGradLabel].ForeColor = System.Drawing.Color.Red;
}
}
}
private void GradPic_MouseDoubleClick(object sender, MouseEventArgs e)
{
for (int i = 0; i < GradPic.Length; i++)
{
if (GradPic[i] == (PictureBox)sender)
{
if (currentView == "Astronauts") ShowAstronautBio();
else ShowGraduateClassPhoto();
}
}
}
Which works fine. I have a similar approach to a different array of pictureboxes, only now the DOUBLECLICK event fires only if I rem out the mouseclick assignment. Anybody have any ideas?
ACThumbBox[i].MouseClick += new MouseEventHandler(ACThumbBox_MouseClick);
ACThumbBox[i].MouseDoubleClick += new MouseEventHandler(ACThumbBox_MouseDoubleClick);
private void ACThumbBox_MouseClick(object sender, MouseEventArgs e)
{
this.ACThumbBox[acGridCurrent].BorderStyle = BorderStyle.None;
for (int i = 0; i < ACThumbBox.Length; i++)
{
if (ACThumbBox[i] == (PictureBox)sender)
{
acGridCurrent = i;
this.ACThumbBox[acGridCurrent].BorderStyle = BorderStyle.FixedSingle;
}
}
}
private void ACThumbBox_MouseDoubleClick(object sender, MouseEventArgs e)
{
DisplayAircraftWebPage();
}
|
|
|
|
|
Have you tried altering what the function does. Like comment out "DisplayAircraftWebPage();" and just putting instead a MessageBox.Show call to see if the event is the problem or whether the DisplayAircraftWebPage() method is the problem. Or you if the control is being designed, check to make sure all the designer event handlers are set to the proper event.
|
|
|
|
|
I put in a breakpoint, it isn't even going to it. If I rem out the single mouse click assignment it works find.
|
|
|
|
|
|
Hi, I'm writing a chat client in C# for the CyanChat protocol, using a TcpClient and C# sockets. All messages sent have the format "XX|message\r\n", where XX is a message ID code.
My problem is that my client is only receiving the first message. Messages sent out are sent properly, but only one message is ever received and shown.
public void GetMsg(IAsyncResult ar)
{
int byteCount;
try
{
byteCount = (chatClient.GetStream()).EndRead(ar);
if(byteCount <1)
{
Disconnect();
MessageBox.Show("Disconnected!!");
return;
}
BuildText(recByte,0,byteCount);
if(!firstTime)
{
AsyncCallback GetMsgCallback = new AsyncCallback(GetMsg);
(chatClient.GetStream()).BeginRead(recByte,0,1024,GetMsgCallback,this);
firstTime = false;
}
}
catch(Exception ed)
{
Disconnect();
MessageBox.Show("Exception Occured :"+ed.ToString());
}
}
public void BuildText(byte[] dataByte, int offset, int count)
{
for(int i=offset; i<(count); i++)
{
if (dataByte[i] == 10)
{
Parse(myBuilder.ToString());
myBuilder = new System.Text.StringBuilder();
continue;
}
myBuilder.Append(Convert.ToChar(dataByte[i]));
}
}
private void Parse(string message)
{
string str = message.TrimEnd('\r');
if(str != "")
{
string[] mes = str.Split('|');
int id = Int32.Parse(mes[0]);
switch (id)
{
}
}
}
I'm not sure why the other messages aren't getting through, but it makes it really difficult to talk to people when you can't see what they are saying.
If anyone can help me figure this out, any help would be greatly appreciated.
Thanks in advance,
Paradox
|
|
|
|
|
Paradox22 wrote:
if(!firstTime)
{
AsyncCallback GetMsgCallback = new AsyncCallback(GetMsg);
(chatClient.GetStream()).BeginRead(recByte,0,1024,GetMsgCallback,this);
firstTime = false;
}
It's this firstTime variable - presumably, it will be set to true when you first come into this method, which means that the code inside the if statement will never get called, so the next messages will not be received. I don't think you need this firstTime variable at all, I'm not seeing what it's doing for you here.
-----
In the land of the blind, the one eyed man is king.
|
|
|
|
|
Hello,
does anyone know if the dialog shown by the ImageEditor (where you can also select Images from your resource-files) in Visual Studio is available as a class somewhere...I would like to invoke it directly without the ImageEditor class used as argument for the EditorAttribute...I tried already to use ImageEditor.EditValue directly (in a method invoked at design-time) but nothing happens.
Thank you
|
|
|
|
|
I have a class:
class DBdata
{
public int id;
public int name;
public int email
blah blah blah
}
This class correlates to a table in the database, as you could probably tell.
I want to show this in Tree View where for example the name is the actually text of the node but the id and email are also encapsulates parts or that data, so that is to say if a drag one node from one tree to the another tree view it will cary its data with it. How can i do this because in a tree view I cant add any object unless it is of type TreeNode.
|
|
|
|
|
Either make the Tag property of each TreeNode in the TreeView point to an instance of DBdata, or create a TreeNode-derived class that exposes it (and then only add instances of the derived node to the tree). The first option is probably sufficient.
|
|
|
|
|
Hello,
I have a DataGridView, with data that is data bound to it. And in one column, I'm trying to data bind a tooltip text with it. Is this possible?
Or should this be done manually, iterating each row and setting the tool tip for that column for each row manually?
Thank you,
Rafferty
|
|
|
|
|
I seem to recall, but am not sure, that when you have a Form.Paint() event,
that it paints its' background and borders, then iterates through all controls issuing their Paint() method.
Now I have some logic that is keying off of the DataGridView.RowPrePaintEvent but I want to make sure that once I did the painting of the rows the very first time, that I no longer go through the long chunky code I have to implement. So my thinking is this:
I overload my Form.Paint method
Form.Paint does a base.Paint();
the base form paint method then calls all the controls
each DataGridView.RowPrePaintEvent is fired and processes correctly.
since it is the first event I also execute the ugly code that is long and bulky
when base.Paint() returns, I can safely say I painted my form the first time and set my state to processed.
Does that sound quite accurate in the sequence of events???
|
|
|
|
|
Hi guys,
I am having a weird problem. I have always had this working and now suddenly after moving to a different computer and reinstalling visual studio 2003.NET; my application doesn't show the tree structure for the FolderBrowserDialog. here is my code for the browse buttons.
private void cmdBrowse1_Click(object sender, System.EventArgs e)
{
TBSrc.Text=GetFolderPath();
}
private string GetFolderPath()
{
string sTemp=string.Empty;
folderBrowserDialog1.ShowNewFolderButton=true;
folderBrowserDialog1.ShowDialog(this);
sTemp=folderBrowserDialog1.SelectedPath;
return sTemp;
}
Please help!!!!
sasa
|
|
|
|
|
Someone mentioned the same issue a few weeks back. IIRC, it was to do with the app running in MTA. Search the forum
|
|
|
|
|
Thank you; you were right, I searched and found the reason and solution.
sasa
|
|
|
|