|
In C#, you access array elements using [] not (),
if (row.Cells[this.invoiceNO.Index].Value == true)
This will access the elements, instead of invoking it as a function.
Indexers (C# Programming Guide)[^]
Methods (C# Programming Guide)[^]
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
many thanks...but i get another error (Operator '==' cannot be applied to operands of type 'object' and 'bool')
|
|
|
|
|
|
Or better, omit the test altogether:
if ((bool)row.Cells[this.invoiceNO.Index].Value)
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
There are 2 more ways to do this, in SO thread.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
it's work......... manythanks
|
|
|
|
|
Hello Every One !
Facing a issue in c# project Named(Sunny Traders) any Help will be appreciated
Error#1 " Unable to copy file "obj\x86\Debug\Sunny_Traders.pdb" to "bin\Debug\Sunny_Traders.pdb". The process cannot access the file 'bin\Debug\Sunny_Traders.pdb' because it is being used by another process"
Error# 2 "Could not copy "obj\x86\Debug\Sunny_Traders.pdb" to "bin\Debug\Sunny_Traders.pdb". Exceeded retry count of 10. Failed. Sunny_Traders"
What i tried is
1.Adding Exception in Antivirus
2.Change in Release and Debug
3.Cleaning Project and Rebuilding
4. What is working for me is to Close VS and delete all files from project->bin->debug ( Sadly i have to repeat No.4 Every time to execute.
waiting for a Solution 
|
|
|
|
|
Try disabling the Visual Studio Hosting Process:
How to: Disable the Hosting Process[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
That is the way it works. Rebyc Rebyc wrote: because it is being used by another process"
All that needs to be done is terminate that program, because you are executing a write operations on a file and in Windows, files are locked from any write operation. Just terminate that program so that content can be updated, then restart the service. You are right, you have to repeat this process, otherwise do not start the debuggers until everything is in its place.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
How to make in C# textBox accept only ,backspace and enter, numbers that are given in 6 textBoxes and only this symbols:
+,-,*,/,(,), and no letters
For example for letters: 6,4,2,3,25,75,50
modified 18-Dec-16 12:24pm.
|
|
|
|
|
I made this but it doesn't work well!!!
private Dictionary<char, int> numbers;
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
string number = tbHint1.Text + tbHint2.Text + tbHint3.Text + tbHint4.Text + tbHint5.Text + tbHint6.Text;
numbers = number.GroupBy(c => c).ToDictionary(g => g.Key, g => g.Count());
if (char.IsDigit(e.KeyChar) || char.IsSymbol(e.KeyChar))
{
char keyPressedByUser = e.KeyChar;
if (!number.Contains(keyPressedByUser))
{
e.Handled = true;
return;
}
int inputCount = textBox1.Text.ToUpper().Where(c => c == keyPressedByUser).Count() + 1;
if (inputCount > numbers[keyPressedByUser])
{
e.Handled = true;
return;
}
e.Handled = false;
}
else
{
e.Handled = true;
}
}
|
|
|
|
|
Let me give you a piece of advice. Keypress is a poor way to verify text input, what happens when the user pastes a value in?
This space for rent
|
|
|
|
|
Build a string of allowed characters and test for the presence of the character entered, for instance to allow only numbers (apologise it is in VB but easy to convert);
Public Const IntegerStrings As String = "0123456789" + ChrW(8)
Public Sub IntegerKeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles tbHigh.KeyPress, tbLow.KeyPress
If IntegerStrings.IndexOf(e.KeyChar) = -1 Then
e.Handled = True
End If
End Sub
Your difficulty arises when you are testing for a compound of digits like 75 and 50 in your example, for this you cannot use keypress but would have to test what was entered when the textbox is complete.
|
|
|
|
|
Please clarify for me what are EventListener, EventHandler, EventRaiser, and CallBack by explaining what each is and giving a code example of each term.
I've been reading articles and watching videos about Events and Delegates and my head is spinning due to the use of the terminologies just mentioned.
The presenters did not give clear explanations as to what they are and it's causing me to have a lot of confusions.
modified 18-Dec-16 9:34am.
|
|
|
|
|
|
|
You've asked enough questions here to know how to ask a question: and linking to code on a different site isn't good.
And just dumping two sets of code on us and saying "it don't work" isn't going to get you very far either.
We've already told you that just blindly converting between Pascal and C# is a good idea.
What have you done to sort this out?
What have you found out about this problem by using the debugger?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I change from bool[] uzet=new bool[6]; to bool[] uzet=new bool[7]; but I get this error:
void oznaci_po_redu(int s)
{
l = 0;
while (s > 0)
{
l++;
if (!uzet[l]) s--; -----Index was outside the bounds of the array--------
}
uzet[l] = true;
}
|
|
|
|
|
Well, clearly you need to find out what value s has before you enter the loop, and why it might be larger than the number of elements.
We can't do that for you: you need the debugger to find out!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Value of s before entering loop was 1
|
|
|
|
|
Then look at the code using the debugger and see exactly what is happening each time it goes round the loop.
It's pretty obvious if you just pay attention to what you have written ... and the debugger would show that that immediately...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
|
No, it's l
void oznaci_po_redu(int s)
{
l = 0;
while (s > 0)
{
l++;
if (!uzet[l]) s--; -----Index was outside the bounds of the array--------
}
uzet[l] = true;
}
But it gets increased while s is non zero, and when does s get reduced?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
My bad. And looking more closely at the code, I now see what you were alluding to.
|
|
|
|
|
A quick visit with Mr Debug would have shown the OP as well!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|