|
Hello,
I'm using the following code to get the number of rows in an Excel worksheet.
range = (Excel.Range)excelWorksheet.Columns["A", Type.Missing];<br />
range = range.get_End(Excel.XlDirection.xlDown);<br />
Console.WriteLine(range.Row.ToString());
It works fine with any number of rows (I've tried up to 2000), however if my worksheet has 1 row in only it returns the total number of rows - 65536. Any suggestions?
Thanks in Advance
Jonny
|
|
|
|
|
Hi Everybody,
Can anyone tell me how we can calculate working hours base on two intervals of time.
like
Starting Date: 17-05-2006 09:00 AM - Ending Date: 17-05-2006 05:00 PM ?
If ending date something like this then what to do?
Starting Date: 17-05-2006 09:00 AM - Ending Date: 18-05-2006 08:00 AM
I'm using C#.Net
|Muhamad Waqas Butt|
waqasb4all@yahoo.com
www.sktech.freewebspace.com
|
|
|
|
|
if you use it as variables of type DateTime then it's not problem.
search the commands and static commands between DateTime, and most importent TimeSpan (TimeSpan - Represents Time intervals), I suggest the TimeSpan\DateTime parse method, and TimeSpan.Substract method.
if you are still having troubles I'll give you a sample code.
|
|
|
|
|
for your request (I got the email... but there is no msg here, so if I would post there you wouldn't get the email notification).
I've built this method, a small method that all you need is two datetimes...
private TimeSpan SubTime(DateTime dt1, DateTime dt2)
{
TimeSpan ts = TimeSpan.Parse(dt2.ToString("H:mm:ss"));
return ts.Subtract(TimeSpan.Parse(dt1.ToString("H:mm:ss")));
}
now you use it like this:
DateTime dateDiff = DateTime.Parse(SubTime(DateTime.Now, DateTime.Now.AddHours(3)));
simple no?
btw I think DateDiff is in SQL... this is C#.
if you want to pick datetime you can use the datetimepicker that has alot of functionality, and very comfort, if you want to display the DateTime you just do in a label, Text property = DateTime1.ToString("formatting")
eg. DateTime1.ToString("dd-month-yyyy hh:mm AM/PM") // just built it for you from a book I have - needed to custom make some stuff.... should work and if theres a problem try to search it, or if theres a real problem send me a msg...
Hope I helped
NaNg.
|
|
|
|
|
Hi all!!
I'm using a DataGridView and sometimes my DataGridViewTextBoxCell's
(due to text wrapping) become bigger then the datagrid height.
When this happens, even if I scroll down, there are some text lines of
each row which never show up.
Is this a bug? Does anyone know a workaround?
Thanks a lot in advance for any hints about this issue...
Pedro
|
|
|
|
|
There is a select commandfield button in the column of a gridview.
How is it possible to replace this button with a value of a text of one of the column cells in that row?
For example: each record in the grid view has a button (select commandfield) which I have called it accept.
This button redirects the user to another page and passes a value from the text in one of the columns.
But for some of these records I would like to show the text of the value of that cell instead of showing the button.
Hope this is clear.
Thanks
|
|
|
|
|
Hi,
How can we pass an enum as a parameter
i.e if i declare enum value1, value2
now how can i pass entire enum
|
|
|
|
|
like a regular veriable?
eg.:
public enum BBB { Vall, Val2, val3 }
public static BBB next(BBB val) { return val+1; }
just a simple use of it...
you can use the whole enum if you include the namespace to your project, or you use the name space (eg. if BBB is in System then System.BBB)
and that's it...
|
|
|
|
|
I wanted to create my own custom ComboBox derived from ToolStripComboBox but ToolStripComboBox does not reveal all of the underlying functionality of the ComboBox (for example, there is no OnMeasureItem in ToolStripComboBox) so I decided to create a class that derives from ComboBox with all my functionality and then create another class that derives from ToolStripComboBox that will use my custom ComboBox. The problem is that this doesn't work either because there is no way to replace the standard ComboBox in the ToolStripComboBox. The ComboBox property in ToolStripComboBox is not virtual and using the new keyword with ComboBox in my derived class still results in the base ComboBox being used. Does anybody know of a way around this?
Thanks
|
|
|
|
|
i have a textbox, a button and a checkbox in my form.
if button click and then checkbox click , in my textbox i can draw rectangle ,this is not problem
but checkbox doubleclick , still i can draw rectangle to the textbox, how can i block this.
my code;
bool bbas=false;
bool rbutton=false;
private void button1_Click(object sender, System.EventArgs e)
{
bbas=true;
}
private void textbox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if(bbas&&rbutton)
{
graphic.DrawRectangle(blackpen,e.X-25,e.Y-25,50,50);
graphic.FillRectangle(blackbrush,e.X-25,e.Y-25,50,50);
}
}
private void checkbox1_CheckedChanged(object sender, System.EventArgs e)
{
rbutton=true;
}
|
|
|
|
|
Hello...
I'm sorry, but I don't no exactly what you want. But I think I can solve the problem.
In the method :
private void checkbox1_CheckedChanged(object sender, System.EventArgs e)
{
rbutton=true;
}
you must change it to :
private void checkbox1_CheckedChanged(object sender, System.EventArgs e)
{
if(checkbox1.Checked)
{
rbutton=true;
}
else
{
rbutton=false;
}
}
or
private void checkbox1_CheckedChanged(object sender, System.EventArgs e)
{
rbutton = this.checkbox1.Checked;
}
Because double click event does not exists in checkbox. That's why, just use .Checked or not to enable or disable drawing.
|
|
|
|
|
if(checkbox1.Checked)
{
rbutton=true;
}
else
{
rbutton=false;
}
helped me , thank you guy
|
|
|
|
|
hi jackalfb!
just a code optimization...
rbutton = checkbox1.Checked;
you can also use this and will get the same result..
microsoc
|
|
|
|
|
|
You should do your drawing in the Paint event.
|
|
|
|
|
tkanks you friends
i think answers will help me.
|
|
|
|
|
How do I loop through the form elements in C#?
Regards,
ma se
(South Africa)
|
|
|
|
|
Just use :
<br />
foreach(Control control in this.Controls)<br />
{<br />
}<br />
<br />
|
|
|
|
|
In addition to stancrm answer, if you want to be able to iterate through all the child controls as well you can use a simple recursion:
private void IterateControls(Control c)
{
if (c.Controls.Count > 0)
{
foreach (Control child in c.Controls)
{
IterateControls(child);
}
}
}
.
.
.
IterateControls(this)
|
|
|
|
|
Thanks to both of you, but just another problem, how would I display the contents of the textbox? I have the ID which I did like control.ID, but now I need the value of the box. I went through the list of options, but couldn't find something like value or so.
Please help.
|
|
|
|
|
|
|
All that I need to do is to loop through the form, check if the control is a textbox, if so, print the ID of the textbox, together with the value typed in the box.
Please help.
|
|
|
|
|
You can check when you are iterating through all the contols to see if it's a textbox like this (if c is your control):
if (c is TextBox)
{
TextBox tb = (TextBox)c;
}
Now that you have casted c to a textbox you should be able to access all it's properties.
|
|
|
|
|
or as an alternative
TextBox tb = c as TextBox
if(tb != null)
{
MessageBox.Show(tb.text);
}
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|