nmaillet 97 Posting Whiz in Training

You could handle the RowsAdded and RowsRemoved events, then implement something like this:

private void dataGridView_RowsAdded(object sender, DataGridViewRowsAddedEventArgs args)
{
    textBox.Text = ((DataGridView)sender).Rows.Count;
}

private void dataGridView_RowsRemoved(object sender, DataGridViewRowsRemovedEventArgs args)
{
    textBox.Text = ((DataGridView)sender).Rows.Count;
}
nmaillet 97 Posting Whiz in Training

OK, so I thought I was on the C# forum with the last reply:yawn:. Check out The Apache POI Project. I've used it before and it's fairly painless.

nmaillet 97 Posting Whiz in Training

If you are using Visual Studio, I believe there are some project templates that aid in this. However, I have never used them. I have had some experience with office and Interop. You will have to add a reference to Microsoft.Office.Interop.Excel (with the correct assembly version; 12 I believe).

using namespace Excel = Microsoft.Office.Interop.Excel;
...
public static void Main(string[] args)
{
    Excel.Application app = new Excel.Application();
    Excel.Workbook workbook = app.Workbooks.Open("testing.xls");
    ...
}

Note that there are classes in this namespace, but C# will not work with these; stick with the interfaces. Also, if you are working in anything before .NET 4.0, you will have to use Type.Missing for all optional parameters, like:

Excel.Workbook workbook = app.Workbooks.Open("testing.xls", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
peter_budo commented: Question was asked in Java section not C#, so do not post irrelevant stuff -4
nmaillet 97 Posting Whiz in Training

The constructor of your derived class, should call the constructor like:

public bcd(int bb) : base(bb)
{
}

You can normally call a base class' methods as if they were the derived class' methods. However, if you override or hide a base class' method, you can call it like:

base.AMethod()

.

nmaillet 97 Posting Whiz in Training

Are you referring to the tab's header? If so, you can just use a StackPanel in the TabItem.Header:

<TabItem.Header>
    <StackPanel Orientation="Horizontal">
        <Path Data="M0,0 L1,0 1,1 0,1 z"
              Fill="#FF737374"
              Width="23"
              Height="23"
              Stretch="Fill"/>
    </StackPanel>
</TabItem.Header>

Unless you intend to utilize the DockPanel in the TabItem's Header, I would not recommend adding it. It just adds unnecessary overhead to your program.

nmaillet 97 Posting Whiz in Training

Did you have a specific question? Or have you made an attempt and can't get something working right? People here will not do your homework for you.

nmaillet 97 Posting Whiz in Training

a

nmaillet 97 Posting Whiz in Training

The .NET Framework does not natively support USB devices. I have never worked in depth with USB devices, however you can try these links to get you started:
http://www.developerfusion.com/article/84338/making-usb-c-friendly/
http://www.icsharpcode.net/opensource/sharpusblib/

Good luck.

nmaillet 97 Posting Whiz in Training

In addition to what can_surmeli said, you router will probably block incoming requests from outside the network. Have you enabled port forwarding to your Mac?

nmaillet 97 Posting Whiz in Training

This is not working since using a literal backspace character will not remove characters from the string. You could check: if(c == '\b') and remove the last character. You will probably have issues if text is inserted in the middle of the text. I would suggest using a DocumentListener :

jTextField.getDocument().addDocumentListener(this);

Then implement a DocumentListener interface:

@Override
public void insertUpdate(DocumentEvent e) {
    System.out.println("insert");
}

@Override
public void removeUpdate(DocumentEvent e) {
    System.out.println("remove");
}

@Override
public void changedUpdate(DocumentEvent e) {
    System.out.println("changed");
}
mKorbel commented: correct suggestion +8
nmaillet 97 Posting Whiz in Training

Having said that, there are some flaws that need to be considered first. In this program, only the last set of tags will be printed to the output. In addition to this, if there is an open tag ( <type:int> ) with no closing tag, it will cause an error.

nmaillet 97 Posting Whiz in Training

Try changing lines 14 and 30 to System.out.println("Index 1: " + index1); and System.out.println("Index 2: " + index2); ; then re-post your output. I looks like, at least in the first couple outputs, index2 is staying at its default value (0).

nmaillet 97 Posting Whiz in Training

On line 29, you are setting index1 where you should be setting index2 .

You should look into using regular expressions and capturing groups for searching and extracting data from strings:
http://download.oracle.com/javase/1,5.0/docs/api/java/util/regex/package-summary.html

nmaillet 97 Posting Whiz in Training

2567</type:int>
5</type:int>
34</type:int>
1</type:int>

From your output, it looks like you are actually looking for <type:int></type:int> tags. If this is the case, then index1 is being set each time, and index2 is not being set. This is because, the match criteria for index1 is ":int>", which would match "<type:int>" and "</type:int>".

Also, shouldn't line 40 be inside the for loop? Otherwise you will only be outputting the last result.

nmaillet 97 Posting Whiz in Training

The Grid class derives from Panel, which has a ZIndex attached property. In XAML you can change the ZIndex like this:

<TextBox Panel.ZIndex="5"/>

In code behind, use the static method:

Panel.SetZIndex(textBox, 5);

http://msdn.microsoft.com/en-us/library/system.windows.controls.panel.zindex.aspx

nmaillet 97 Posting Whiz in Training

Please post some of your source code, and giving the location displayed in the properties window. Am I correct in assuming you mean that the location is changing between where it is in the designer, and where it is when the program is running? If so, looking at the Form constructor and InitializeComponent() method would be a good start.

nmaillet 97 Posting Whiz in Training

The API doc does say protected Object clone() yes. The source code, shows it with the native keyword.

nmaillet 97 Posting Whiz in Training
protected native Object clone() throws CloneNotSupportedException;

Notice the native keyword. This means that the method is not implemented using Java, but using native code (C/C++) using the Java Native Interface (http://java.sun.com/docs/books/jni/).

nmaillet 97 Posting Whiz in Training

You cannot have a Vector() and a Vector(...) constructor. Constructors with a variable number of parameters could have 0 parameters. Which is equivalent to Vector() . The compiler is uncertain of which constructor to call. You have to remove the parameter-less constructor and perform a check in the other constructor for the number of parameters passed. Hope that helps.

nmaillet 97 Posting Whiz in Training

It is an issue with operators, not parentheses in this case:

else if (age > 19 && bmires2 > 18.50 && bmires2 < 25.00)

This would work for you. Since you would only be using the AND operator, there is no need to worry about the order in which the statements are evaluated. You may want to add parentheses for readability, such as:

else if (age > 19 && (bmires2 > 18.50 && bmires2 < 25.00))

but this is not necessary. This just makes things blatantly obvious for others. Take a look at the link ddanbe posted.

nmaillet 97 Posting Whiz in Training

Your using the OR operator when you should be using an AND operator. If you say bmires2 >= 18.50 || bmires2 <= 25.00 , it will always evaluate to true. Therefore the only thing that would affect the statement is age > 19 .

Just for instance, if bmires2 = 10.00 , then bmires2 >= 18.50 is false, but bmi <= 25.00 is true. Given this, true AND false will evaluate to true.

In my personal experience, whenever I am using a mixture of AND's and OR's, I use parentheses to avoid any confusion.

ddanbe commented: Good! +14
nmaillet 97 Posting Whiz in Training

Store a reference to the first Form's Label as a local variable in the second Form. Then, create an Event handler for the TextBox's TextChanged event, and set the Label's Text property.

nmaillet 97 Posting Whiz in Training

Are the Oracle assemblies installed on the client's machine?

nmaillet 97 Posting Whiz in Training

The preprocessor directives are listed here:
http://msdn.microsoft.com/en-us/library/ed8yd1ha.aspx

The #pragma directive only supports warning suppression and ASP.NET file checksums. You can use the Debug class in System.Diagnostics to write to the Output window:
http://msdn.microsoft.com/en-us/library/6x31ezs1.aspx

Hope that helps.

nmaillet 97 Posting Whiz in Training

The only thing I can think of:

[DllImport("user32.dll", SetLastError = true)]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);

private const int GWL_STYLE = -16;
private const int WS_SYSMENU = 0x00080000;

private void Window_Loaded(object sender, RoutedEventArgs e)
{
    IntPtr handle = new WindowInteropHelper(this).Handle;
    SetWindowLong(handle, GWL_STYLE, GetWindowLong(handle, GWL_STYLE) & ~WS_SYSMENU);
}

This will however, remove the minimize, maximize and close buttons as well. I don't know of any other way around it...

nmaillet 97 Posting Whiz in Training

It looks like you are missing a bunch of semi-colons ( ; ) and curly braces ( {} ), and the #endif preprocessor directive should be on its own line. Are those missing in your code, or did they not get copied over somehow? If they weren't copied, please repost your code and, like WaltP said, give us some more information.

nmaillet 97 Posting Whiz in Training

How are you creating the installer? Are you using a Visual Studio wizard? Or are you trying to install some generic program you downloaded/purchased? Need more information.

nmaillet 97 Posting Whiz in Training

The .NET Framework installation may be corrupted; System.EnterpriseServices should be installed with the .NET Framework. Trying running a repair or reinstall, from Add/Remove Programs or Programs and Features on that computer.

nmaillet 97 Posting Whiz in Training

Installed() is a method contained within another class. In addition, it is marked as private. You could change the installed method to:

public static string Installed()

The static keyword allows the method to be accessed without creating a new Class1. Now, you can reference it by calling:

MessageBox.Show(Class1.Installed())

You need to explicitly state the class that the method is contained in, unless it is contained in the same class.

nmaillet 97 Posting Whiz in Training

Strings are immutable objects. That is, whenever you make a "change" to a string, a new string is created, and you reference the new string.

To replace the last character:

oldmassiveoutput = oldmassiveoutput.Substring(0, oldmassiveoutput.Length - 1) + " ";
kvprajapati commented: Or.. System.Text.StringBuilder :) +15
nmaillet 97 Posting Whiz in Training

You could store a local variable in the parent Form, and implementing the GotFocus event in each of the children. Then update the variable in the parent Form by casting the Owner property.

nmaillet 97 Posting Whiz in Training

In the Button's Click event:

tabControl1.SelectedTab = tabPage2
nmaillet 97 Posting Whiz in Training

Arrays can certainly use double values. However, to reference a double value in the array, or declare its size, you use an int. This is because, you refer to each location as 0, 1, 2, etc.

For example:

double[] a = new double[] {0.1, 0.2, 0.3};
double[] b = new double[] {0.2, 0.4, 0.5};
int length = a.length;
double[] c = new double[length];
for(int i = 0; i < length; i++) {
    c[i] = a[i] + b[i];
}

would work. Just notice that I gave c a length of type int, and referenced the arrays using the int i, but I was using a array of doubles. Let me know if this clears things up a bit, or if it needs to be any clearer.

nmaillet 97 Posting Whiz in Training

If I understand what you are asking correctly, you could just wrap everything from line 20 to the end of the switch statement in a while(true) loop.

nmaillet 97 Posting Whiz in Training

The size argument in your constructor should be an int. This is because, the size of an array uses int. In addition, in your for loops (constructor and sort() method), you should be using int as the indexer. Again, arrays use int to reference their index. As well, floating point numbers occasionally given unexpected results like 4.32 + 3.68 = 7.999999997 (this particular example does not actually in this case, but have had similar results in the past).

nmaillet 97 Posting Whiz in Training

You could use the Regex class to do this. You would use a string such as \\(.\\) (with RegexOptions.SingleLine to have the dot (.) operator include every character). Then use the Regex.Replace() method.

http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.aspx

nmaillet 97 Posting Whiz in Training

I am assuming you are referring to multiple threads accessing the display() method, from the same object instance. If so, your code would cause some inconsistent errors (may work perfectly, or may fail). This is because instructions between multiple threads do not, by default, completely execute an entire method before allowing another to execute. What may happen: size gets set in thread 1, then size gets set in thread 2, then the following instructions are executed.

Try adding synchronized to the display() method:

public synchronized void display(){
	int size = getSessionSize();
	if(size==0){
		setSession();
		System.out.println("1");
	}else{
		destroySession();
		System.out.println("2");
	}
}

This will ensure the method completes execution by one thread, before another can execute it. What concerns me, is that the other public methods are susceptible to the same issues. Not necessarily within the method, but by the executing objects. You should read up on threading and concurrency.

Good luck.

nmaillet 97 Posting Whiz in Training

Sorry, yes it will only throw an exception if there is a constraint violation, whether updating values or inserting rows.

nmaillet 97 Posting Whiz in Training

Yes it will, it is similar to a primary key or not null constraint. It will also throw an exception if you attempt to change the values after it is created.

nmaillet 97 Posting Whiz in Training

You should always try and enforce data integrity at the source. This allows for multiple applications to access the data, without each needing to be coded individually (error prone). And a small bug in the application will not cause the data to become invalid. That said, you can add a CHECK constraint to the table:

ALTER TABLE TheTable
ADD CONSTRAINT chk_TheTable CHECK (ColumnA >= ColumnB)

Something like this will work for Microsoft's SQL Server, I can't say for certain about other servers.

nmaillet 97 Posting Whiz in Training

You could simply declare/initialize four integers to hold the number of bills for each. Divide the withdrawal amount by 1000 (int / int to remove the remainder), and subtract the result from the number of thousands. Then subtract the result multiplied by 1000 from the withdrawal amount. One thing you'll need to consider: after getting the result, check it against the number of remaining bills and adjust accordingly. Then just go through the list of remaining bills.

nmaillet 97 Posting Whiz in Training

In your first for loop the statement i < wrd[i] should be replaced by either: wrd[i] != NULL or i < strlen(wrd) .

You are comparing i to the character code, which works fine when you are limited to twelve characters, since the lowest printable character is 32 (a space). However, if you went beyond that your code would stop working properly.

nmaillet 97 Posting Whiz in Training

For your first question, there are a few methods. If you are not using binding, then you could handle the TextChanged event, although this can be quite messy. If, however, you are using binding, you can perform validation in two possible locations: at the source or at the target. The target being your control.

In order to validate from the target, you would first have to create a custom validation rule by deriving from the ValidationRule class, for example:

public class RangeValidation : ValidationRule
{
    private double _max;
    private double _min;
    public double Max
    {
        get
        { return _max; }
        set
        { _max = value; }
    }
    public double Min
    {
        get
        { return _min; }
        set
        { _min = value; }
    }
    public override ValidationResult Validate(object value, CultureInfo cultureInfo)
    {
        try
        {
            double val = double.Parse(value as string);
            if (val > Max)
                return new ValidationResult(false, "Value is greater than the max value.");
            if (val < Min)
                return new ValidationResult(false, "Value is less than the min value.");
            return new ValidationResult(true, null);
        }
        catch (Exception exc)
        {
            return new ValidationResult(false, exc);
        }
    }
}

Then you would add it to your Binding for TextBox.Text:

<Binding.ValidationRules>
    <local:RangeValidation Max="100.0" Min="0.0"/>
</Binding.ValidationRules>

You could setup your Min and Max values as DependencyProperty's of DependencyProperty's of your UserControl.

It doesn't sound like you would be validating from the source, however if you were, you would simply add a ValidateValueCallbackHandler in the DependencyProperty.Register method.

For your second control, I would first …

nmaillet 97 Posting Whiz in Training

Hey, could you elaborate on the issue you are having?

nmaillet 97 Posting Whiz in Training

You can use the API, found at http://java.sun.com/javase/reference/api.jsp. Just choose the JDK version you're looking for under Core API Docs.

nmaillet 97 Posting Whiz in Training

What have you tried? What's it doing wrong? The source code would be useful.

nmaillet 97 Posting Whiz in Training

If you need to create your own copy function, first open the original file for reading, then create (or a file with that name exists) for writing. Then you could simply read a byte in the original file, then write that byte to the new file. This is simple to program, however very inefficient in terms of time if it is being copied to the same disk. A better solution might be to create a buffer (just an array of bytes), fill the buffer then write the buffer. Hope this helps.

nmaillet 97 Posting Whiz in Training

Where are the DLL's stored, are they included in the installer? Or are they just somewhere on the computer? Because libraries are looked for in the folder with the executable or in any folders defined by the Path environment variable.

nmaillet 97 Posting Whiz in Training

As long as the DLL's are located in the same folder as the executables it should work without any issues.

nmaillet 97 Posting Whiz in Training

The Paint event is raised when the Form is first shown, this is to give the Form its initial appearance. When you show a Form it enters a message loop. Messages are sent from the Operating System. If you look at the Windows API, there are some flags that determine when the window should be redrawn (e.g. horizontal or vertical resize). The paint event can also be called from within the application. The form creates a Graphics object, filling it with the background colour of the form, then when the Paint event has finished calling all of the delegates it can use the Graphics object to write the pixels to the monitor.

Hope this helps to clarify things.