|
Thanks Heath, I just got a printed copy of your article so I can go over it the old fashion way when I take subway tonight.
Norman Fung
|
|
|
|
|
Hello,
I am having a little trouble with using the windows forms datagrid control. In my program, I need to give the user the ability to select and unselect multiple rows in the datagrid and then perform some action on those selected rows.
Initially, I was hoping to use checkboxes. I made a bool column in my database and added a checkbox column in my datagrid. This appeared to work okay. When I wanted to determine the selected rows, I just iterated through my data table and looked at the value of the column that was bound to the checkbox column. However, I soon found a problem with this approach. I have a "Select" menu, with different options that select thousands of rows in the datagrid (such as select all, select none, etc.) In order to do this, I needed to change the value of many checkboxes at once, and this is very very slow because I am having to edit each row in the corresponding datatable.
I've been trying to figure out other ways to get the same functionality, and I thought that maybe I could just use the built-in select in the datagrid (highlighting the entire row). I was able to select large numbers of rows much more quickly this way because I wasn't modifying any data in the datatable. However, now I have another problem. I don't know how to relate a row in the datagrid to the correct row in the datatable. I've found some code examples such as this:
BindingManagerBase bm = dataGrid1.BindingContext[dataGrid1.DataSource,dataGrid1.DataMember];
DataRow dr = ((DataRowView)bm.Current).Row;
But, this only works for the current row. What if I have a list of the row indexes in the datagrid, and I want to iterate through that list and perform actions on the correct row in the datatable?
Also, I really prefer the checkboxes over the highlighted rows. Is there a way that I can implement checkboxes without having to make a column in my datatable?
Any ideas would be great!
Thanks,
Blake
|
|
|
|
|
as i do,
dataGrid1.DataSource = DataView1
DataView1.Table = "//correct_datatable"
you can get corresponding row via DataView1
Ex:(to get i-th DataRow )
DataView1.Item[i].row
|
|
|
|
|
Hello there.
I'm not sure if this forum is the correct place to post my quest. But I was searching for so long to get any information about a way to show Crystal's database progress from within an application. Business Objects (distributor) says there is no way. Actually the technical support of Business Objects is not worth mentioning, is it?
If there is defacto no way, I wonder why Crystal Reports is such a successful tool. There must be threads or processes on the system that are running invisibly.
So perhaps there's no way to picture the progress at all is there a possibility to catch the end of the crystalreportviewers work? If that I could show a waitcursor at least.
My report app is build in c# (on a windows system of course) and I have installed Crystal Reports 9 Developer Edition.
Hopefully
T. Labenche
|
|
|
|
|
Being a little impatient, aren't you? Posting your question once an hour will not get it answered any faster.
Anyway, CR doesn't expose any kind of event that you can use to monitor its database progress. Since CR itself doesn't know how many records are going to be returned beforehand, there is no way to tell when the progress will end.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
That is what I feared for. Anyway, thanks for your reply.
Another thing: You are not that kind of person who reprimand without reflections, are you? Perhaps a crash of the IE was the reason why I have (unwittingly) posted the message twice. Sometimes I might be impatient, but I am by no means impatient when I'm expecting unkind messages!!!
Even though
Best regards
T. Labenche
|
|
|
|
|
I want to do a simple search function in a richtextbox. I have loaded a file and by using the Find method it's possible to find a text string, highlight the string and extract the line number, but how can I programatically scroll down to the line?
private int findText(string searchText, int searchStart, int searchEnd)
{
int indexToText = richTextBox1.Find(searchText, searchStart, searchEnd, RichTextBoxFinds.MatchCase);
richTextBox1.SelectionColor = Color.Blue;
int lineNo= richTextBox1.GetLineFromCharIndex(indexToText);
return indexToText;
}
|
|
|
|
|
Why not just use the ScrollToCaret() method of RichTextBox ?
Regards,
mav
|
|
|
|
|
Embarrisingly enough I tried that first but discrded as not working. Just to find out that the control needed focus before it worked...
So it was just to add
richTextBox1.Focus();
richTextBox1.ScrollToCaret();
|
|
|
|
|
Hello there.
I'm not sure if this forum is the correct place to post my quest. But I was searching for so long to get any information about a way to show Crystal's database progress from within an application. Business Objects (distributor) says there is no way. Actually the technical support of Business Objects is not worth mentioning, is it?
If there is defacto no way, I wonder why Crystal Reports is such a successful tool. It is hardly reasonable to customers I think. There must be threads or processes on the system that are running invisibly.
So perhaps there's no way to picture the progress at all is there a possibility to catch the end of the crystalreportviewers work? If that I could show a waitcursor at least.
My report app is build in c# (on a windows system of course), VS 2003 and I have installed Crystal Reports 9 Developer Edition.
I'm looking forward to any information.
Hopefully
T. Labenche
|
|
|
|
|
In VC++ when I used to write a Windows Service, I used to parse the command line arguments. If it is '-install' I used to call functions OpenSCManager() and CreateService() to register the service OR DeleteService() to remove it from the SC manager. (winsvc.h )
I am new to VC#... Please tell me the equivalent functions/code piece to do the above task. I am keen on doing this programmatically (if possible, off course) rather than using the installutil and stuff…
|
|
|
|
|
use ServiceInstaller Class
Look into MSDN for help
Sanjay Sansanwal
www.sansanwal.com
|
|
|
|
|
I am trying to use Excel.WorksheetFunction.VLookup but cant use it. Can someone give me an example of how i should use it. I dont seem to be able to get up any of the WorksheetFunction members when using VS which leads me to think that i need to initialise something.
|
|
|
|
|
hi,
Check this article.
http://www.codeproject.com/csharp/csharp_excel.asp
http://www.codeproject.com/aspnet/getsheetnames.asp
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Thanks for your input but they dont use any WorksheetFunctions so i still need help
|
|
|
|
|
Excel.WorksheetFunction wsf = ThisApplication.WorksheetFunction;
Thought i had found all my answers but my app doesnt have ThisApplication defined as i am not using the VS MS office templates. So what do i need to replace ThisApplication with to get this working?
|
|
|
|
|
Hi,
I hope I'm understanding the problem correctly. You can get an reference to the app through:
Excel.Application app = new Excel.ApplicationClass();
Then there are two ways I can think of to evaluate functions:
object result = app.Evaluate("=LEN(\"ABC\")");<br />
double lnVal = app.WorksheetFunction.Ln(System.Math.E);
and don't forget to quit Excel:
app.Quit();
Hope this helps
|
|
|
|
|
Thankyou, that was the answer i was looking for.
|
|
|
|
|
Hi all,
I've wrote a scheduling application for someone and it needs to be running permanently in the system tray which is all done and works fine. During testing i came up with a problem though.
When Form.Close() is called i check for a password that has been hardcoded into the application. When the PC is shut down i want the program to close without user intervention as the machines will be used off site and the admins will be the only ones with the password.
In short i need to be able to check for a password when Form.Close() is called by the user and not check when it is called by the System shutting down.
Hope you can help.
Kev
|
|
|
|
|
hi,
You can check the user name and password when you call form.close() method. If you want to do some additional work(checking user name and pwd) on the time of closing then you need to override the oncloseing event.
protected override void OnClosing(CancelEventArgs e)
{
try
{
if(MessageBox.Show("This Will Close your form. Do You Want To Continue ?","Conformation",MessageBoxButtons.YesNo,MessageBoxIcon.Information) == DialogResult.No)
{
e.Cancel = true;
//This block will execute if he refuse to close the form.
}
else
{
//This block will execute if he deside to close the form. So you can put your logic here for checking the credentials.
e.Cancel = false;
}
base.OnClosing (e);
}
catch(Exception Ex)
{
MessageBox.Show(Ex.Message.ToString(),"Information",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
This will help you to check the user name and password.
And i am not much sure about how handle the shutdown process.;)
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
OK, Lets try to make things a little clearer.
I can already check for the password using the Form.Closing event.
<br />
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)<br />
{<br />
SaveSchedules();<br />
<br />
if (!(CheckPassword()))<br />
e.Cancel = true;<br />
else<br />
notifyIcon.Visible = false;<br />
}
CheckPassword() returns a bool depending on the password entered.
The above bit is the easy part, what i need to do is to know wether
the user is closing the aplication by clicking on the cross on the form
or the system is closing the application because the user has tried to log
off / shut down the PC.
Kev
P.S. How do you get the Yellow background behind code samples??
|
|
|
|
|
exhaulted wrote:
P.S. How do you get the Yellow background behind code samples??
using the menu below (if u reply a message) or using the "code" tag.
to u'r question, i'm not sure u can, in managed code.
there are no facts, only interpretations
|
|
|
|
|
The code tag just makes things red .
I wondered how people put large code samples in with yellow backgrounds, like in Articles
Kev
|
|
|
|
|
Use <pre> tags.
Charlie
if(!curlies){ return; }
|
|
|
|
|
thanks
Kev
|
|
|
|