Click here to Skip to main content
15,887,485 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# Specified cast is not valid Pin
harold aptroot22-Dec-16 22:39
harold aptroot22-Dec-16 22:39 
GeneralRe: C# Specified cast is not valid Pin
Richard MacCutchan22-Dec-16 22:54
mveRichard MacCutchan22-Dec-16 22:54 
GeneralRe: C# Specified cast is not valid Pin
OriginalGriff22-Dec-16 22:12
mveOriginalGriff22-Dec-16 22:12 
AnswerRe: C# Specified cast is not valid Pin
OriginalGriff22-Dec-16 22:11
mveOriginalGriff22-Dec-16 22:11 
AnswerRe: C# Specified cast is not valid Pin
Nelson Costa Inácio22-Dec-16 22:42
Nelson Costa Inácio22-Dec-16 22:42 
GeneralRe: C# Specified cast is not valid Pin
harold aptroot22-Dec-16 22:45
harold aptroot22-Dec-16 22:45 
GeneralRe: C# Specified cast is not valid Pin
OriginalGriff23-Dec-16 0:05
mveOriginalGriff23-Dec-16 0:05 
AnswerRe: C# Specified cast is not valid Pin
Pete O'Hanlon23-Dec-16 0:00
mvePete O'Hanlon23-Dec-16 0:00 
There are a couple of things I notice about your code. The first thing I see is that you use a switch statement unnecessarily. As each array item you drop into is 1 away from the value in brojKlikova, you can use a simple subtraction to allocate the correct value.

The second issue you have is that you have no idea what's in Tag. It may, or may not, be an int. If I were you, I would use something that is suited to test and convert a value into an int. Specifically, I would use int.TryParse to see if I could actually convert from whatever is in Tag to an int.
C#
int tagValue;
this.trenutneKontrole[brojKlikova-1] = button.Image;
if (!int.TryParse(button.Tag, out tagValue))
{
  pokusaj[brojKlikova-1] = tagValue;
}
else
{
  System.Diagnostics.Debug.WriteLine("The value in the Tag for {0} is not an integer", brojKlikova);
}
Run the application and watch the Output window to see which one of your Tag values triggers this. It's that simple.
This space for rent

AnswerRe: C# Specified cast is not valid Pin
Gerry Schmitz23-Dec-16 6:50
mveGerry Schmitz23-Dec-16 6:50 
GeneralRe: C# Specified cast is not valid Pin
Richard MacCutchan23-Dec-16 6:59
mveRichard MacCutchan23-Dec-16 6:59 
QuestionWhat is this JWT Code Doing? Pin
TheOnlyRealTodd21-Dec-16 15:46
professionalTheOnlyRealTodd21-Dec-16 15:46 
GeneralRe: What is this JWT Code Doing? Pin
Richard MacCutchan21-Dec-16 21:54
mveRichard MacCutchan21-Dec-16 21:54 
GeneralRe: What is this JWT Code Doing? Pin
TheOnlyRealTodd21-Dec-16 22:35
professionalTheOnlyRealTodd21-Dec-16 22:35 
GeneralRe: What is this JWT Code Doing? Pin
OriginalGriff21-Dec-16 23:24
mveOriginalGriff21-Dec-16 23:24 
GeneralRe: What is this JWT Code Doing? Pin
Gerry Schmitz22-Dec-16 4:07
mveGerry Schmitz22-Dec-16 4:07 
AnswerRe: What is this JWT Code Doing? Pin
Richard Deeming22-Dec-16 2:35
mveRichard Deeming22-Dec-16 2:35 
QuestionNeed help on how to if record exists update else insert c# Pin
Bootzilla3321-Dec-16 7:56
Bootzilla3321-Dec-16 7:56 
AnswerRe: Need help on how to if record exists update else insert c# Pin
Michael_Davies21-Dec-16 8:04
Michael_Davies21-Dec-16 8:04 
AnswerRe: Need help on how to if record exists update else insert c# Pin
Richard Deeming21-Dec-16 8:06
mveRichard Deeming21-Dec-16 8:06 
AnswerRe: Need help on how to if record exists update else insert c# Pin
Nelson Costa Inácio21-Dec-16 23:34
Nelson Costa Inácio21-Dec-16 23:34 
QuestionC# PictureBox remove image Pin
Pavlex420-Dec-16 11:21
Pavlex420-Dec-16 11:21 
AnswerRe: C# PictureBox remove image Pin
Pavlex420-Dec-16 11:39
Pavlex420-Dec-16 11:39 
GeneralRe: C# PictureBox remove image Pin
Mohan Baro20-Dec-16 18:10
Mohan Baro20-Dec-16 18:10 
GeneralRe: C# PictureBox remove image Pin
Pavlex420-Dec-16 20:11
Pavlex420-Dec-16 20:11 
SuggestionRe: C# PictureBox remove image Pin
Ralf Meier20-Dec-16 21:19
mveRalf Meier20-Dec-16 21:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.