|
Hi
the code below incrments by 1 each time and adds1 to the end number, is there a way for it to increment 01,02,03 rather then 1,2,3
string[] split = db.Split('_');
string s_number = split[1];
int i_number = Int32.Parse(s_number);
i_number++;
s_number = i_number.ToString();
db = split[0] + "_" + s_number;
cheers
|
|
|
|
|
You can use String.Format()[^]. You can find the right format string in the examples.
Standards are great! Everybody should have one!
|
|
|
|
|
1 is a number which you can increment.
01 is a string representation of a number. You cannot increment a string as it has no real meaning to do so.
You should increment you number (1) and then apply string formatting to that number (myNumber.ToString("00")) to get the required format.
|
|
|
|
|
Guess you missed my other reply
Yeah, either .Format("00");
or like i said last time .PadLeft(2, '0');
My current favourite word is: Bauble!
-SK Genius
|
|
|
|
|
ok so should it be added somewhere in the line below as this is the entire format of what is being outputted?
db = split[0] + "_" + s_number;
|
|
|
|
|
Instead of getting someone here to hold your hand all the way through... try some stuff out yourself next time given the hints that have been provided.
db = split[0] + "_" + s_number.ToString("00");
|
|
|
|
|
well done thats great thats what ive already tried which is why i posted the question
db = split[0] + "_" + s_number.ToString("00"); this does not work error message is there are invalid areguments in the code
|
|
|
|
|
it should be this:
s_number = i_number.ToString("00");
not
db = split[0] + "_" + s_number.ToString("00");
|
|
|
|
|
well done.
|
|
|
|
|
Hi,
I have a datatable which is going to fill from a if statment (I mean I don't know which record is going to returned) and after the data is returned i want to be able to edit or delete the returned records.
(the IF's are a search statment all on one table and diffrent columns)
so when S.O wants to delete a record i want to refresh the Grid which is filled with datatable.
how can i refresh the datatable.
(I hope i was able to express what I mean)
please help me.
|
|
|
|
|
I strongly advise to use SQL to get only the data you want.
If this is not possible you will have to use loop to step through all returned rows and fill a new DataTable with only the rows you want (ImportRow) (no a DataView won't help if you can't use SQL to filter).
If you may use LINQ it's getting simpler - just use where with your IF
(for example:
<br />
<br />
var FilteredDT = from c in originalTable<br />
where (c => (statements from the if for c - for example c.Name.StartsWith("x")))<br />
select c;<br />
<br />
|
|
|
|
|
I have the following code and one progress bar (websites are navigated at run time and web site list may be more than this)
<br />
for (int kk = 0; kk < 3; kk++)<br />
{<br />
web = new WebBrowser();<br />
web.Url = new System.Uri(websitelist[kk], System.UriKind.Absolute);<br />
web.Navigate(websitelist[kk]);<br />
hashTable.Add(kk, web);<br />
}
How can I get summation of progress of all webbrowsers in just a single progress bar i.e., their progress can be shown in single progress bar? If I am having a single webbrower I can get progress values by using their event handle, but when I have run time browers control and going on increasing how can I use event handling for all browsers(stored in hashtable as objects)
like :
foreach (int kk in hashTable.Keys)<br />
{ <br />
......<br />
...<br />
}
|
|
|
|
|
I don't think you can get the progress of the web control (no use anyway because if you set the URL or Navigate in a WebBrowser-Control the statement will only return after the site was loaded - so you would have to use a asynchron version).
Why don't you just use (kk+1.0)/websitelist.Count as a hint?
(If not you will have to load the sites yourself ... I don't think you will enjoy the work)
|
|
|
|
|
Thanks for a reply!
websites are navigated for a long time in hashtable. I don't know when they all are finished their work(navigation). There may be speed bandwidth problem, so I have to check their current progress. I think counting will not solve this problem.
|
|
|
|
|
Hi,
each WebBrowser generates its own WebBrowserProgressChanged event, and the
WebBrowserProgressChangedEventArgs offer both current and max values.
From all these numbers you can calculate overall progress any way you choose,
one possibility is 100% * sum(current) / sum(max)
(be careful with the initial situation when not all of the current & max values
have been reported yet).
|
|
|
|
|
|
Hi
I have the following code which is counting how many instances of room_code there are in table room_schdule. I know there is two counts of it in there, but my if statement at the bottom is not working, any clues?
cheers
string test0003 = "Select count (room_code) from room_schedule where room_code = '" + room_code + "'";
string max5;
SqlCommand cmd01 = new SqlCommand();
cmd01.Connection = con2;
cmd01.CommandText = test0003;
max5 = cmd01.ExecuteScalar().ToString();
if (max5 < 2)(it shouldnt perform this statement but it is)
do something
else
do something
|
|
|
|
|
Try
<br />
int imax5 = Convert.ToInt32(cmd01.ExecuteScalar());<br />
if (imax5 < 2)<br />
{<br />
...<br />
}<br />
The problem is "string" < "integer" - I wonder why your compiler is processing this without warning.
|
|
|
|
|
thanks that sorted it cheers
|
|
|
|
|
Hai i am doing program using list i need to add item to list using first,next,last buttons contioniously when i press previous button it should display the previous item in the list plz any on help me in this case
|
|
|
|
|
well.. the last item in the list will be the total number of items... -1
Actually, -2, since arrays always start at 0.
Then after that everytime you click previous you go one lower. So you'd have to have some variable for the current item your looking at.
My current favourite word is: Bauble!
-SK Genius
|
|
|
|
|
You can use the LinkedList( Of T) or use the index (like the other poster mentioned) ... it's not that hard
|
|
|
|
|
hi
1-i have a detaset that filled with a sp
2-i added a column later to sp
3-i go to dataset designer and tried to configure it
4-the new column does not exists in dataset column list
5-i check the connection string , i ran sp from server explorer and management studio 2005 both worked, i refresh my solution refresh my server explorer,reboot my compter, i taked deep breathes,...
none of them helped , so can u help me?
I Wish the Life Had CTRL-Z
|
|
|
|
|
Hi,
I want to write a windows app that will switch my network connections.For example if i have three service providers and if the one i am using now goes down i can switch to the other on a button click.
i plan to keep three buttons and on the buttonclick of these plan to change the connections.ie button1 will connect met to one particular providers internet connection and hence forth regarding the other buttons.I am stuck till here .i think from here i need help.how can i make the computer to switch between the connections?Can any body give me any suggestions or links regarding this?
Thanking You
|
|
|
|
|
Hi,
im using propertygrid and trying to show boolean property with other string values than true/false,
i made boolenconverter for this, it works fine when i use combobox to change value, but i get inner propertygrid error when i doubleclick to change value in propertygrid:
Invalid property value!
Details: Cannot widen from target type to primitive type.
<br />
public class BaseProps{<br />
<br />
private bool test;<br />
<br />
[TypeConverter(typeof(BoolNameConverter2))]<br />
public bool Value {<br />
get {return test;}<br />
set {test = value;}<br />
}<br />
<br />
}<br />
<br />
<br />
public class BoolNameConverter2 : StringConverter<br />
{<br />
<br />
private const string m_trueDisplayName = "on";<br />
private const string m_falseDisplayName = "off";<br />
<br />
public override bool CanConvertTo(ITypeDescriptorContext context,<br />
System.Type destinationType) <br />
{<br />
if (destinationType == typeof(bool))<br />
return true;<br />
<br />
return base.CanConvertTo(context, destinationType);<br />
}<br />
<br />
public override object ConvertTo(ITypeDescriptorContext context,<br />
CultureInfo culture, <br />
object value, <br />
System.Type destinationType) <br />
{<br />
if (value is bool && destinationType == typeof(System.String)) {<br />
return (bool)value ? m_trueDisplayName : m_falseDisplayName;<br />
}<br />
return base.ConvertTo(context, culture, value, destinationType);<br />
}<br />
<br />
public override bool CanConvertFrom(ITypeDescriptorContext context,<br />
System.Type sourceType) <br />
{<br />
if (sourceType == typeof(string))<br />
return true;<br />
<br />
return base.CanConvertFrom(context, sourceType);<br />
}<br />
<br />
public override object ConvertFrom(ITypeDescriptorContext context,<br />
CultureInfo culture, object value) <br />
{<br />
if (value is string) {<br />
return (string)value == m_trueDisplayName ? true : false;<br />
} <br />
return base.ConvertFrom(context, culture, value);<br />
}<br />
<br />
public override bool GetStandardValuesSupported(<br />
ITypeDescriptorContext context) <br />
{<br />
return true;<br />
}<br />
<br />
public override StandardValuesCollection<br />
GetStandardValues(ITypeDescriptorContext context) <br />
{<br />
return new StandardValuesCollection (new string[]{m_trueDisplayName, m_falseDisplayName});<br />
} <br />
<br />
public override bool GetStandardValuesExclusive(<br />
ITypeDescriptorContext context) <br />
{<br />
return true;<br />
}<br />
<br />
}<br />
<br />
What could be the problem? Has anybody had similar problem and has solution? How to fix it?
Thanks
Deglimmer
|
|
|
|