Posts by Jéf Bueno • 67,331 points
1,254 posts
-
2
votes3
answers155
viewsA: Why should I use the typeof keyword to assign a data source to a Bindingsource.Datasource?
Why should I use the keyword "typeof" to set a Datasource in a Databinding? You shouldn’t. I don’t know where you get it from, but it doesn’t make any sense. There is no way to give more details,…
-
3
votes1
answer683
viewsA: Sort lists with two sort criteria
You can do it like this listaOrdenada = sorted(lista, key = lambda x: (x[1], x[0])) The lambda past says that the first ordering criterion is the column 1 and the second ordering criterion is the…
python-2.7answered Jéf Bueno 67,331 -
4
votes3
answers2350
viewsA: Add multiple items to a list
Your reasoning is almost right, the only difference is that the method AddRange() gets a IEnumerable<T> instead of several T's. The use would be: ContasNegativas.AddRange(new [] {30301, 30302,…
-
0
votes2
answers792
viewsA: Sort list of lists
You can use the function sorted and pass as second parameter to key ordination to be made listaOrdenada = sorted(lista, key = lambda x: x[1])
python-2.7answered Jéf Bueno 67,331 -
5
votes4
answers3199
viewsA: Check if String is number, if not, return error to user
There are several ways to do this, how you will do it depends on a little taste and also the complexity of your application, but come on. If it is a small application and you only intend to validate…
-
4
votes1
answer1358
viewsA: Catch Penultimate record of a table with Entity Framework
You can do it like this: var penultimoRegistro = db.Entidade.OrderByDescending(/*ordenação*/).Take(2).Last(); What this code does is take the last two records according to the specified ordering and…
-
1
votes2
answers1773
viewsA: Java args pass file as parameter
Instead of trying to pass the files by parameter, pass the file path and instate with the class File in the application. public static void main(string[] args){ for(String arq : args){ File file =…
-
3
votes3
answers178
viewsA: How to capture a Nullreferenceexception?
First, reinforcing what @Maniero said Please never use one try-catch if you are not sure what you are doing. It is not solution, it is increasing problem. From what I understand and can see from the…
-
3
votes1
answer4652
viewsA: Change color of a given cell
Thus dataGridView.Rows[rowIndex].Cells["nomeDaColuna"].Style.BackColor = Color.Yellow;
-
3
votes1
answer155
views -
8
votes2
answers576
viewsQ: Notice: "Possible Multiple enumeration of Ienumerable"
I was doing some operations where I use collections. In one of these I needed to take a break (range) of numbers and I did the following: var range = Enumerable.Range(0, 4); And then I tried to do…
-
2
votes1
answer8783
viewsA: How to set Grid View column width?
Via design First click on the arrow in the upper right corner of the DataGridView and click on Edit Columns. This will open a form with all the columns of your Grid, so you select in the column you…
-
1
votes5
answers1382
viewsA: No return on method?
No way to know exactly the reason without you showing the file. But it is very likely that the file does not have any lines, causing the code within the while (which is the part that gives a value…
-
2
votes1
answer29
viewsA: Use Where Enclosure when class is dynamic
Although I can’t see a reason to do so. The most I can think of right now to solve this problem is to ask for a Func<T, bool> instead of a string. See in practice public class…
-
2
votes1
answer183
viewsA: Sort nodes from Tree view
Yes, it is possible. You must create your own Comparer to and define it as property value TreeViewNodeSorter of TreeView public class NodeSorter : System.Collections.IComparer { public int…
-
5
votes1
answer160
views -
6
votes1
answer115
viewsA: Internal X public access modifier
The access modifier public makes your method/property (or anything else) accessible from anywhere in your application (or others). This means that it will be possible to access the element even if…
-
3
votes1
answer1097
views -
2
votes1
answer72
viewsA: Get character index based on Width
I don’t think there’s anything ready for that. My tip is: Take a letter from the text while the text is longer than the image. Ex.: while(texto.Length > imagem.Width) { texto =…
-
5
votes3
answers753
viewsA: Does Java have a class to work with command line arguments?
Yes, there is. You know that class main(String[] args) what is the entry point of your application? It is in this variable args that the parameters entered when calling the application are stored.…
-
11
votes7
answers1690
viewsA: Hexadecimal for RGB
In C# var cor = System.Drawing.ColorTranslator.FromHtml("#FFFFFF"); var corEmRgb = System.Drawing.Color.FromArgb(cor.R, cor.G, cor.B); And to do it backwards var cor = Color.FromArgb(255, 255, 255);…
-
1
votes2
answers342
views -
4
votes3
answers3895
viewsA: Double click on a Datagridview line transports the data to a form
There are several ways to do this. It depends a lot on your preference/need and some other factors like DataSource of DataGridView. First, your Form to edit client must be able to receive a…
-
3
votes1
answer2415
viewsA: Take values from only one row of a table
That one query $selec = "SELECT * FROM usuarios"; You are selecting all records from the table usuarios. Here $row = mysql_fetch_array($selec_query); $row receives a result line (the first in this…
-
2
votes1
answer3982
viewsA: Error: "in module named xxxx"
You are trying to import modules that do not come "embedded" when you install Python. That means you will have to install them manually. You can do this by Pip pip install numpy Or however you…
-
0
votes4
answers788
viewsA: Generate random values from a distribution in Python
You need to download the module in order to use it. Type in the terminal (or cmd) pip install scipy
-
0
votes3
answers167
viewsA: How to delete node in linked list?
Your question is not very clear. What I understood was that you have a list with 4 elements and want to remove a specific one. This can be done as follows: var lista = new List<int> {1, 2, 3,…
-
3
votes2
answers995
views -
3
votes1
answer132
viewsA: Doubt with Webapi data insertion
See, the error says (my emphasis) The request Entity’s media type 'text/Plain' is not supported for this Resource. When it’s time to do the POST for Postman you need to change the content type for…
-
1
votes2
answers166
viewsA: How to use Measurestring method?
Solution valid only for Windows Forms If your goal is to obtain an object Size the size of your string, you can use the method MeasureText class TextRenderer thus var size =…
-
13
votes3
answers29788
viewsQ: Measuring the run time of a function
How can I measure the running time of a Python function? In C#, I can use the class Stopwatch in that way var sw = new Stopwatch(); sw.Start(); AlgumaFuncao(); sw.Stop(); WriteLine(sw.ElapsedTicks);…
-
3
votes1
answer729
viewsA: I can’t change the value of variables inside a loop
See, you defined the array with the answers as follows respostas = ['A', 'B', 'C', 'D', 'E', 'E', 'D', 'C', 'B', 'A'] At the time of validating what the user has typed, you are doing item =…
-
6
votes1
answer1947
viewsA: How to drag form without border?
You can do it this way. At the event MouseDown is defined that the user clicked the form and the point he clicked is saved in the variable clickedAt. At the event MouseMove is verified if the user…
-
2
votes1
answer654
viewsA: Error to import mysql table into phpmyadmin
That line Telefone VARCHAR(45) NOT NULL, should be Telefone VARCHAR(45) NOT NULL
-
3
votes2
answers763
viewsA: What is the best way to read a sql server error return?
You’re hiding your mistake by doing this catch (Exception ex) { } Don’t do this. Hide the exceptions never is a good idea. Probably just take out this block catch will help you enough. It is very…
-
1
votes3
answers2520
viewsA: Search for file with only part of its name in C#
You can do using Linq var arquivos = diretorio.GetFiles().Where(x => x.Name.EndsWith(ParteFinal)); If you are sure there is only one file, you can use the Single() var arquivo =…
-
4
votes1
answer94
views -
7
votes1
answer130
viewsA: Time difference in Linq
You cannot do arithmetic operations with types DateTime when using the Entityframework. If you are using Entity Framework 5.0 or later You must use DbFunctions. Import the namespace…
-
0
votes1
answer128
viewsA: Which version of Itextsharp
Always prefer the latest version of the libraries you are using. If this will not cause you any incompatibility problems, of course. The latest version available on iTextSharp is the 5.5.7. To put…
itextsharpanswered Jéf Bueno 67,331 -
2
votes1
answer2298
viewsA: Pass method parameters through the URL
First of all, these parameters are called query string. You can declare in your method for it to accept requests HTTP GET [WebMethod] [ScriptMethod(UseHttpGet=true)] public string…
-
6
votes1
answer858
viewsQ: What are controller actions?
In that reply the Gypsy says This (example) is good when you have several Actions in the Controller What are the Actions of a Controller? Note: I would like some example of code as well, defining a…
-
5
votes4
answers542
viewsA: Why use block using in ASP.NET MVC?
The using {} block works the same way in both web and desktop applications in the sense of when we use it in the controller? Yes, works the same way. The using is nothing more than a try finally,…
-
3
votes3
answers752
viewsA: Comparison between objects through loop, If and Else?
First of all, if and else are not loops. They are conditional operators. for and while do loops, that is, they repeat the same instruction diverse times until a certain condition is met. Other than…
-
1
votes2
answers1223
viewsA: How to get all data from one table based on another table?
Without its complete structure it is difficult to help you. But with the information you gave in the question, you can already find a mistake, you say I have a countries table and another table with…
-
11
votes2
answers6808
viewsQ: What is the difference between Carriage Return and line feed?
There are two different ways to break a CR line (Carriage Return) and LF (line feed). What is the difference between these two? When should one or the other be used? Depends on the system? Language?…
-
3
votes4
answers3646
viewsA: Capture selected value in grid checkbox
You need to go through all the lines on DataGridView and check whether the CheckBox is marked in this way foreach(DataGridViewRow linha in dgView.Rows){ // passar por todas as linhas do dg var cell…
-
2
votes1
answer712
views -
1
votes2
answers1501
viewsA: Put files inside a. zip file
If you are using a version earlier than Java 7, the best way to do this is to unzip the files inside the .zip and play along with the new files in a new .zip. Based in Soen’s reply. private static…
-
10
votes2
answers455
viewsQ: String Interpolation performs better than string. Format?
I use Resharper and a few days ago I started using some C# 6 features. In various parts of the code use string.Format() and I realized that Resharper suggests that these snippets be replaced by…
-
45
votes2
answers48974
viewsA: What does public Static void main(String[] args) mean?
public It is the access modifier of the method. Using this modifier the method can be accessed by any class inside (and outside) of the project. Other modifiers are protected, private or…