|
I don't know you what actually you want to accomplish, But to just remove % you can loop through each rows and columns and use following.
table.Rows[i][j].ToString().Replace("%", String.Empty);
Regards,
Hiren.
-"I don't know, I don't care, and it doesn't make any difference".
|
|
|
|
|
Here are two suggestions:
1.
Each column of a DGV has a default style which you can alter; here is a typical statement doing that:
dgvArticles.Columns[DGVA_COL_BOOKMARKS].DefaultCellStyle.Format="#,###";
This would set the style of all data cells in one column, it probably is what you want.
For numbers you can specify different styles for positive, negative and zero values.
2.
Every time a cell is going to be recalculated for later painting, a DGV cell fires its CellFormatting event. You can assign a handler, that determines the style to be used at run-time, and this for individual cells. Here is another (partial) example:
private void dgvUsers_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) {
if (e.RowIndex...) {
if (e.ColumnIndex...) {
e.CellStyle.BackColor=Color.Gold;
}
}
}
FYI: both examples were inspired by actual code inside my "CP Vanity" article.
BTW: the above is NOT changing the value in the cells, it is only changing the way the cell content looks.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Hi ,
How can we make sure that which part causes error in MStest failure. ?.Please let me know.
With Thanks regards.
|
|
|
|
|
Could you please be descriptive about the problem.
"The worst code you'll come across is code you wrote last year.", wizardzz[ ^]
|
|
|
|
|
I am working on the code part only.MSTest is written by some1 else.When I run the MStest after making changes to few files in a project , it is getting failed.I just want to know which change in which file triggering the error in MStest.Any idea ?
|
|
|
|
|
You will have to look at the test case which is failing and see which method it is testing. The error should be a clue.
"The worst code you'll come across is code you wrote last year.", wizardzz[ ^]
|
|
|
|
|
Show code and message.
More help would come.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
Hi all,
In my system in a service is running at the backend.I want to use that service in my windows application how can i do it ?
An exe file for that service also i am having. But how can i use that service in my application.
Thanks in advance.
|
|
|
|
|
Is it a windows service? Or a web service?
"The worst code you'll come across is code you wrote last year.", wizardzz[ ^]
|
|
|
|
|
Its a windows service which is already running, but i am not having any svc or any other file.Only exe file of that service is available.
|
|
|
|
|
What do you mean by "using" it? If you want to start or stop the service, you can use ServiceController class.
If you need to call a method from the service, you should not be using the service at all. If it has class library collection for the business layer and data access etc, use them as reference in your application.
"The worst code you'll come across is code you wrote last year.", wizardzz[ ^]
|
|
|
|
|
You have not mentioned, How you want to use that service?
SVC file is only required to register a service as a windows service, so a simple .EXE file can be register as windows services.
You can directly use that Exe file and execute it using Shell command.
Regards
Rushi
|
|
|
|
|
hi,
I have used the below code on datagridview1_ColumnHeaderMouseClick
foreach (DataGridViewColumn x in datagridview1.Columns)
{
x.SortMode = DataGridViewColumnSortMode.Automatic;
x.Selected = true;
}
sorting is not happening ...
even i have tried...
private int Order=-1;
the below code is inside datagridview1_ColumnHeaderMouseClick
Collapse | Copy Code
ListSortDirection sortDirection;
if (this.datagridview1.SortedColumn.Name == "Number")
{
if (this.Order == -1)
{
sortDirection = ListSortDirection.Descending;
datagridview1.Sort(datagridview1.Columns["Number"], sortDirection);
datagridview1.Columns[e.ColumnIndex].HeaderCell.SortGlyphDirection = System.Windows.Forms.SortOrder.Descending;
this.Order = 1;
}
else
{
sortDirection = ListSortDirection.Ascending;
datagridview1.Sort(datagridview1.Columns["Number"], sortDirection);
datagridview1.Columns[e.ColumnIndex].HeaderCell.SortGlyphDirection = System.Windows.Forms.SortOrder.Ascending;
this.Order = -1;
}
}
even the above code is not working....
please help me regarding the same....
|
|
|
|
|
Hi,
a DGV is a complex Control. I got it sorting any way I want, see e.g. my "CP Vanity" article.
From memory, and maybe not 100% accurate:
1. It would not sort (but throw some exception) when databound to something that does not implement IBindingList; that is why I often use a DataTable, not just a List as a data source.
2. It would sort in the natural way when set to Automatic, without requiring any extra code.
3. It could be made to sort in odd ways by setting to Programmatic and calling Sort() explicitly, again see CP Vanity.
Note: I would never change the sort mode inside a click handler, in fact I think the sort mode for each column typically should be constant throughout the app's life, it may be different amongst columns, but I see no need to change it over time.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
modified on Tuesday, May 10, 2011 11:31 PM
|
|
|
|
|
Hi, how can i get the real html code in a webbrowser object??? a mean, if the page has the following code:
Document.write("Text");
i wanna get the code after the js runs. what i want is to get this:
Text
thanks,
Marcus.
|
|
|
|
|
I'm not sure, however I would try this:
- make sure your Internet Explorer has JavaScript enabled;
- use a WebBrowser;
- have it Navigate(string) to the URL you want;
- use it's DocumentCompleted event to obtain its Document property.
Caveat: complex pages may fire their DocumentCompleted event many times; what I typically do is compare the current WebBrowserDocumentCompletedEventArgs.URL with the original one, until they match.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Thanks, but webbrowser1.DocumentText doesnt work, it gets:
<html>
<body>
Document.write("Text");
</body>
</html>
=/ i dont know what to do anymore.
|
|
|
|
|
I'm not sure the "final HTML" actually exists at all; it could well be the browser interprets the incoming data and processes it on the fly, yielding data structures with displayable items that will eventually be shown.
This[^] and other Google hits suggests there is a way, not necessarily an easy one. Start studying "DOM".
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I think it exists, firebug shows the final HTML, but ok... i will look for DOM. Thanks anyway!!
Marcus.
|
|
|
|
|
The thing to remember is that the final HTML may well be rendered out and extended using something like jQuery to append additional content.
|
|
|
|
|
There's no such thing as the "final HTML". Documents can be modified by any number of scripts and by any number of actions on the web page and at any time AFTER the document complete events fire. Click a button and a DIV might disappear. There's no way to tell.
Your concept of a "final HTML" just doesn't exist, even more so today with more script, Flash, AJAX, HTML5, ... HTML is far from a static entity.
|
|
|
|
|
|
Hi guys,
First of all - I am not very experienced. I have the following strage situation:
Task t = null;
t = Task.Factory.StartNew(() =>
{
while (true)
{
// do some calculations
LogToUi("some result");
Thread.Sleep(15000);
}
});
LogToUi is a function that updates a textbox in the UI. It does it pretty straightforward tbUpdateMe.Text = passedtoLogToUiText;
This works just fine, it also works if I use a listbox instead of textbox, but If I would like to change LogToUi to update a datagridview - it does not work.
I was told that in general what I have written should not work.... But it does... So why?
A friend of mine told me that even with textbox it should not work... But it does... So what is the situation and can I expect that it will work with TextBox but not very stable or what?
|
|
|
|
|
So long as your LogToUi method is invoking to the UI thread then any control can be updated successfully. If not, you will end up with illegal cross thread exceptions, or your app may crash (eventually!) if you have these turned off.
|
|
|
|
|
Invoke is required, here[^] is more about it.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
modified on Tuesday, May 10, 2011 5:56 PM
|
|
|
|