Posts by Jéf Bueno • 67,331 points
1,254 posts
-
6
votes1
answer589
viewsA: Modify visual element by another thread
Since you haven’t shown the code of what you’re trying to do, I’ll give a more general answer. You can do it this.Invoke(new MethodInvoker(() => textBox.Text = "NovoTexto")); I would do a…
-
1
votes2
answers106
viewsA: Error changing static property value
You are trying to access a non-static property within a static property. From what I understand of your business rule, this property does not need to be static. So, you just need to exchange her…
-
3
votes1
answer449
viewsA: Add line to Datagrid with Datasource defined
It is possible to do this, setando one BindindList<> as DataSource. So whenever an item is added from BindingList<> it will be automatically inserted into DataGridView. var source = new…
-
3
votes1
answer449
viewsQ: Add line to Datagrid with Datasource defined
I have a DataGridView who has the DataSource setate with List<MinhaClasse> and would like to add a new line to it. I know this is not possible using the method AddRow() of DataGrid. Is there…
-
2
votes1
answer107
viewsA: Xmltextreader.Getattribute returns the null value
The problem is that the return of xmlreader.GetAttribute("count") is being null and, as the error itself says, the value passed to int.Parse() cannot be null. The mistake I don’t really know where…
-
6
votes2
answers10649
viewsA: Check if a word is within a sentence
In addition to using the Contains() to validate whether a string exists within another, you can also use StartsWith() to check whether a string begins with determined string, or the EndsWith() to…
-
2
votes2
answers3604
viewsA: Specified conversion is not valid
What could be done to store the query value. Count() in an int variable or to use in if()? You can convert your query to a list and use the property Count var count =…
-
3
votes2
answers319
viewsA: Like passing a Char to the bank?
The solution is to trade in your PreparedStatement of setInt() for setString(). st.setString(4, String.valueOf(usuario.getSexo())); Using the setInt() the variable char will be converted to Integer…
-
2
votes1
answer7043
viewsA: Sqlexception: Parameter IN or OUT absent from index:: 10
That line String sql = "INSERT INTO USUARIO (EMAIL_USUARIO, NM_USUARIO, SENHA_USUARIO, TP_SEXO, DT_NASCIMENTO, FOTO_USUARIO, NM_LOCALIZACAO, NM_SOBRENOME, NM_NOME) VALUES (?,?,?,?,?,?,?,?,?,?)"; Has…
-
4
votes2
answers15191
viewsA: How do I know if a list is empty in Python?
Just for curiosity purposes. You can also do it in the "ugly way". Still supposing that a is a list a = [] if len(a) == 0: # Condição se for vazio if a == []: # Condição ser for vazio…
-
2
votes1
answer1201
viewsQ: Difference between varchar2 and nvarchar2
In Oracle, there are two types of data that I can use to represent texts, the varchar2 and the nvarchar2. What is the difference between these two types of data?…
-
11
votes2
answers604
viewsQ: Read all the contents of a text file
I need to read all the contents of a text file and put it into a string. Usually, I do so: using(var reader = new StreamReader("arquivo.txt")) { var strBuilder = new StringBuilder(); while…
-
16
votes2
answers604
viewsA: Read all the contents of a text file
No . NET Framework 2.0 and later, the class File has the method ReadAllText() that does just that. The code above would look like this: var texto = File.ReadAllText("arquivo.txt");…
-
4
votes2
answers181
viewsA: Return a similar path value
First of all, you couldn’t use Directory.EnumerateFiles() because you must not have imported the namespace System.IO, because it works on . NET Framework 4.0. This solution takes all files within a…
-
1
votes1
answer45
viewsA: Unity Error Developing an Online Project
You need to add the reference to namespace in which his class PlayerBehaviour is in class Online. Ex.: using umNamespace; public class Online {...}…
-
2
votes3
answers533
views -
5
votes1
answer828
viewsA: Getenumerator error while rendering a View
As the error itself says: Foreach instruction cannot operate on variables of type 'Operator.MVC.Models.Operadormodel' Your mistake is here: foreach (var item in Model) Model is a variable of the…
-
2
votes2
answers3466
viewsQ: Select all references to a given table (Foreign key)
I need a way to select all the Foreign key of a particular pk. In other words, I want to catch a determined Primary key and select all the Foreign Keys that "point" to her. Preferably I want to get…
-
7
votes3
answers17415
viewsA: Mysql field type change
Yeah, that’s gonna work. In my opinion, there is no reason to seek another way of doing if this way works perfectly. Alternatively you could create another column to save the new value (BIT) and…
-
3
votes2
answers286
viewsA: Difficulty transcribing a console application program for windows form(C#)
You’re playing the values on label and not concatenating them, it makes each loop label.Text have a different value. Whenever you do Console.WriteLine() a new line is written. Already when you do…
-
1
votes2
answers579
viewsA: How to convert a date that is in string format in the database when doing a query?
It is very likely that the result of date('now') does not come in format dd/mm/yyyy (the standard is yyyy/mm/dd). You can apply a formatting with strftime() so that the return of date() be in the…
-
1
votes2
answers2241
viewsA: Exit loop when string is empty or when typing a specific word
Just to complement the @Math response. Basically your error is logical. You are checking every turn (loop) if the variable nomeProduto is empty or has the value =, when in fact, you have to check…
-
2
votes1
answer79
viewsA: Pull without using Git Bash
The Git GUI does not have the command pull, however a git pull is nothing more than a git fetch followed by a git merge. You need to go on Remote Menu > Receive from > Remote System to do the…
-
5
votes3
answers2024
viewsA: Keep application (Windows Form) open in icon tray with C#
To send the application to the system tray, you can add a NotifyIcon in the designer of your form and make it visible whenever you want to minimize or (in this case) close the application. To add a…
-
18
votes2
answers10850
viewsQ: What is the main difference between int. Parse() and Convert.Toint32()?
In C#, there are two ways (among others) to convert other types to int: Convert.ToInt32(valor) and Int32.Parse(valor). What is the main difference between these two forms of conversion?…
-
12
votes1
answer3277
viewsQ: How does the Linq Aggregate() extension method work?
I just saw some examples that used the method Aggregate() of namespace System.Linq, but I couldn’t find any good explanation for how to use it. What does this method and how it should be used?…
-
3
votes2
answers3291
viewsQ: Obtain the number of decimals of one decimal
How can I get the number of decimals of a variable decimal? Ex.: If I receive the number: 4.5 - you must return 1 5.65 - you must return 2 6.997 - must return 3 I know what you can do by converting…
-
4
votes1
answer538
viewsA: Angularjs + PHP: How should data be consumed?
How should this be done? Through REST, or there is another way? You need to have an API (in most cases it is used REST but I’ve seen with SOAP) that will be consumed in your application Angular. Who…
-
0
votes2
answers57
viewsA: Do a search for my site in two tables
You can join the result of two selects using the UNION ALL Example: SELECT nome, descricao, 'empresa' AS tipo FROM tbl_empresas where descricao like 'palavra%'; UNION ALL SELECT nome, descricao,…
-
6
votes0
answers53
viewsQ: What is a Python metaclass?
What is a Python metaclass? On what occasions should they be used?
-
5
votes3
answers4588
viewsA: Algorithm with structure PARA and SE
I’ve never used Visualg, but I think your code should look like this var nome , sexo: literal i, c, fem, masc : inteiro inicio para c <- 1 ate 56 faca nome := "" sexo := "" escreval ("Digite seu…
-
3
votes3
answers3518
viewsA: How to solve the problem "The main method was not found" in a Java class?
You need to have a method with the following signature public static void main(String[] args) this will be the entry point of your application. It will be the first method to be executed and is…
-
6
votes5
answers1656
viewsA: Create objects within a list without for/foreach C#
Yes, you can use the method AddRange() and Enumerable.Repeat() for that reason. private List<Compra> CriarCompras(int numComprasParaGerar) { var lista = new List<Compra>();…
-
3
votes2
answers156
viewsA: Error: Cannot find data type long
See what the mistake says Column, Parameter, or variable #1: Cannot find data type long. Parameter or variable@Idcatorigem has an invalid data type. There is no data type long in SQL Server, the…
-
4
votes4
answers570
viewsA: Extend x Superscript, what’s the difference?
Extend When you extend a class (abstract or not), you are causing the new class to have all the methods and attributes of the class you are extending. If you extend the class below class Animal{…
-
1
votes1
answer94
viewsA: What’s wrong with running Hibernate Query?
Check out the first line of stack trace Unknown column 'usuario0_.telefone' in 'field list' That means Hibernate couldn’t find his spine telefone, check if the name is not wrong or you have not…
-
2
votes1
answer1277
viewsA: Combobox search only items that match the typed
You just need to change the property DropDownStyle for DropDown, then change the properties AutoCompleteMode for anything other than None and AutoCompleteSource for ListItems. Applying in your code:…
-
12
votes1
answer22992
viewsA: Access Mysql with C#
First thing: you’re trying to connect to Mysql using SqlCeConnection which is a class to connect to SQL Server. To connect to other databases you need to use providers third party (in the case of…
-
2
votes2
answers777
viewsA: C# Regular expression for string and Guid validation
It’s very easy to do both, see: using System; using System.Text.RegularExpressions; using static System.Console; public class Program { public static void Main() { string str = "palavra1-2-3"; Regex…
-
1
votes1
answer234
viewsA: Disable button when selecting item in Datagrid
In Windows Forms you can use the event CellEnter(). This event is triggered whenever you click on a cell (when the cell receives focus). Example: private void dataGrid_CellEnter(object sender,…
-
3
votes1
answer633
viewsA: Tray Icon Windows
I found two ways to do what you need. One of them is settar your kind of JFrame for JFrame.Type.UTILITY. Obs: You can only change the kind of JFrame while he is not yet visible. Obs2: I tested with…
-
6
votes2
answers10665
viewsA: How to get time difference between two Datetime variables in C#
You need to use TimeSpan for that reason. Example: using System; using static System.Console; public class Program { public static void Main() { var dt1 = DateTime.Now; var dt2 = new DateTime(2015,…
-
2
votes1
answer94
viewsA: stretch label horizontally on a panel in c#
Assuming you want to change by the way Design of Visual Studio, you can settar the property Autosize of Label for False and change property Dock for Top, but this will cause the Label stay "glued"…
-
4
votes4
answers630
viewsA: How do I use the F2 key to open another form?
You need to use the property KeyCode and compare it with the Enum Keys to check which key is being pressed. Example: private void Form1_KeyPress(object sender, KeyPressEventArgs evt){ if(e.KeyCode…
-
8
votes4
answers2280
viewsA: String Manipulation - split()
All answers are correct, but I find it interesting to add that, taking into account that the surname will always be the last word of string, you can do the following: String nome = "Dan Lucio…
-
9
votes6
answers65532
viewsA: Sum in 2 inputs and appear in real time - Javascript
I’m leaving my answer, only as an alternative to the others. In the example I am using the event onfocus to trigger the function that calculates the two inputs when the user click on in the first…
-
8
votes1
answer153
viewsQ: How do branches in GIT work in relation to SVN?
It is known that in the SVN, when one creates a branch (or even a tag), a copy of all the files of trunk to the folder inside the directory branches. Little by little I’ve been using git and I…
-
5
votes2
answers3435
viewsA: Compile multiple java files in the same folder
You need to compile all the files .java and not just the Main. Since you did not put which command you are using to compile, I assume this is your mistake To do this you can run the command: javac…
-
4
votes1
answer4386
viewsA: netbeans change java jdk
It is possible to change the JDK that Netbeans uses by changing its settings file. Footsteps: Open the file netbeans.conf which is in the folder etc within the Netbeans installation folder Change…
-
5
votes1
answer8213
viewsA: Error compiling C in gcc: No such file or directory
Error says you could not find the file main. c. To compile the file, don’t just log in to cmd and type gcc file. c -o executable Either you need to be in the folder the file is in, or you need to…