|
I want to check whether the content in a datagrid cell has been changed or not... how can u achieve this?
samitha
|
|
|
|
|
The cell itself doesn't record anything - the underlying data set does. If you're binding to a DataSet , DataTable , or DataView , get the DataRow for the row for that cell and query the DataRow.RowState property.
There's several ways to do this. The easiest that takes sorting into account is like so:
CurrencyManager cm = (CurrencyManager)
dataGrid1.BindingContext[dataGrid1.DataSource,
dataGrid1.DataMember];
if (cm != null)
{
DataView view = (DataView)cm.List;
DataRowView rowView = view.Item[dataGrid1.CurrentRowIndex];
bool changed = rowView.Row.RowState == DataRowState.Modified;
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
thnks 4 the reply...My actual requiremnt is this..
Suppiose u have a datagrid with only one row has been entred. When you click on the close button on the form(without giving the focus on any other control) it should check whether the row has a value. This ckeck happens correctly when u click else where on the form or on the next row and then try to close..
can anybody help me...?
samitha
|
|
|
|
|
Please state your actual requirement next time. It will save time.
You should still get the currency manager like I showed you in the first reply in your Form.Closing event handler. Then you can call CurrencyManager.EndCurrentEdit . See the method documentation for CurrencyManager.EndCurrentEdit for an example.
You could also use DataGrid.EndEdit , which also includes an example of usage in the method documentation in the .NET Framework SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi All,
I am trying to write an application like, that will do some jobs with the given time interval. Program reads from a text file, which like below...
-------------------------
job1 : 15 minute
job2 : 5 minute
job2 : 25 minute
program place a System.Timers.Timer() for each job, and add ElapsedEventHandler(OnTimedEvent); to do job. The problem is I could not tell the OnTimedEvent code what to do
private static void OnTimedEvent(object source, ElapsedEventArgs e)<br />
{ <br />
<br />
System.Windows.Forms.MessageBox.Show(null,"selam","naber"); <br />
}
how to set a parameter to pass this event an make it special for the job.
karanba
|
|
|
|
|
Derive a new timer from System.Timers.Timer and add a string (or any other data).
public class NewTimer : System.Timers.Timer
{
public string Name;
public NewTimer()
{
}
}
then use this class rather than System.Timers.Timer:
T1=new NewTimer ();
T1.Name = "Timer1";
T1.Interval = 4000;
T1.Elapsed +=new System.Timers.ElapsedEventHandler (this.vHandleTimer);
Then look at the NewTimer in your event hander:
private void vHandleTimer (object sender, System.Timers.ElapsedEventArgs e)
{
NewTimer T=sender as NewTimer ;
MessageBox.Show(T.Name );
}
Hope this helps!
Bill
|
|
|
|
|
Is it possible to add only the needed .NET dll's to an application as a resource to "pre-extract", so that a machine you are deploying your application to, does not need huge .NET framework installed for it to work? OR is there a way to capture the native code that the JIT compiles out of the MSIL and create a PE with it, or will something like that not include garbage collection, etc ?
|
|
|
|
|
|
Ahh, thank you very much sir! This is exactly what I was looking for and could never find.
|
|
|
|
|
Hi,
I am building a website which opens a site map in a child window (window.open - popup window) which displays in links to navigate for users.
How do i do this -
When the users clicks on the child window link, the parent window must load that particular page.
any suggestions? easy one i think...
|
|
|
|
|
Your question would be better handled in the ASP.NET Forum. Even though your app is being written in C#, it really has nothing to do with the language itself. Your question has everything to do with the ASP.NET technology though...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I thought u knew the answer! Rather than useless msgs you can post in the answer if you know!
$iva
|
|
|
|
|
He wasn't posting a "useless msg", he was politely pointing you to the correct place to post your question. I don't know the answer so i can't post what you want, but it looks like you haven't even taken the previous posters advice and posted your question on the ASP forums.
When someone is trying to advise you on how to get the quickest solution to what you want, you'd be better off taking there advice, rather than posting stupid replies like the one above.
Kev Pearman MCP
|
|
|
|
|
Another ungrateful S.O.B. has made it on to my BlackList!
Thankfully, this is a rare event and will not stop me from helping other people, like pointing them in the right direction, in the future.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
If I insert an image in the RichTextBox at runtime, can I drag/move it inside the RichTextBox with the help of mouse, just like we can move any control on the form during design time.
Please guide
|
|
|
|
|
I have a datagrid with this structure:
Column1 Column2 Column3
Name URL FilePathtoSaveTo
There are 1000 rows in the grid and I want to use the url (Column2) in an httpwebrequest and httpwebresponse to get web pages and then use the FilePathtoSaveTo (Column3) to write the web page to disk.
Anyone know of a foreach loop (or some other way) that will allow me to do this (return the cell values from columns 2 and 3 in order to be used as variables for my web request and write?)
Thanks,
Paul
(Also, the urls return text files that when saved with the .html extension, open as html files.)
|
|
|
|
|
Well WHAT is your data source for the Grid? You need to iterate over your data source, NOT the data grid
|
|
|
|
|
Sorry, it is a dataset.
The main point is that I want to take a record
then assign the value from that row, column2 to the variable that contains the url
and then assign the value from that same row and column3 to the variable that will hold the pathname.filename to save as.
I just haven't figured out exactly how to do it yet.
(I've actually got to run now, but I'll be back later tonight)
Thanks,
Paul
|
|
|
|
|
Something like this:
DataTable table = theDataSet.Tables[0];
foreach(Row aRow in table.Rows)
{
string Url = aRow[1];
string SavePath = aRow[2];
}
You can also use the name of the column instead of the ordinal position.
Does this help?
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
Roman Doug and Colin
Thanks to all of you.
This is very cool and it works great.
Thanks for pointing me in the right direction.
Paul
|
|
|
|
|
bool keepGoing = true;<br />
for (int rowNum = 0; keepGoing; rowNum++)<br />
{<br />
try<br />
{<br />
<br />
}<br />
catch<br />
{<br />
keepGoing=false;<br />
}<br />
}
This will probably work, but I don't particularly like it...if you have a dataset with the information, you might want to iterate through that instead of the grid itself.
- D
|
|
|
|
|
So I simply designate the cell by iterating over the rows and then designating the column like this dataGrid[rowNum][2]?
That simple?
I'm using a dataset.
Thanks,
Paul
(I've got to go now...be back later tonight.)
|
|
|
|
|
Actually, I messed the syntax up. You can get the value of a cell with:
dataGrid[rowNum, colNum]
I agree with the other post about using the dataset instead of the grid...but if you have to, you can use the grid. Keep in mind that if you use the datagrid instead of the dataset, you will have to find a way of counting the rows. This is why I used the try/catch block of stopping the loop in my example. I'm sure there are better ways...I'm just too lazy tonight to look anything up. Also, if you use the datagrid, you may have to check the values you get from the cells to make sure they are usable. If the grid is editable, you'll (almost) always have that extra row at the bottom that will have nothing, but you'll still be able to return the value from those cells.
Good luck!
- D
|
|
|
|
|
I have a C# application. This C# application also has file types associated with it (in my case, the extenion is .drb). I want to have a DIFFERENT icon compiled within my .exe that these file extensions use, however, I cannot figure out HOW to add additional icons to be compiled within my application for use by these extensions?
Am I making sense?
|
|
|
|
|
Add an icon file to your project, select the file in Solution Explorer and now in the Properties pane change the Compile property to "Embedded Resource".
After that follow standard procedure for adding file associations/icons.
|
|
|
|