|
You're going to have to test on your own machine.
On mine, 2,000,000,000 iterations of % or bitwise mask with 0x01 can be done in 494 to 499 milliseconds using either operation.
So, how picky do you want to be with a couple thousands of a second across 2 billion operations?
|
|
|
|
|
I won't be that picky. It's more a question of curiosity.
|
|
|
|
|
Hi,
I have a DataTable named dt .
It has 4 columns and 2000 rows. Columns are Code, Department, Part, Status, respectively. In my app, Department can be 4 checkboxes (Electrical, Mechanical, R&D, Industrial Engineering). Part can be checkboxes named North, East, West. Status can be checkboxes named Ended, In Progress.
I have checked Electrical and Mechanical in Department checkboxes, West and North in Part checkboxes, Inprogress in Status checkboxes (it can take any order of checked checkboxes).
I want to remove rows which don't satisfy my conditions (remove based on checkboxes)
What is the best solution?
I think I should create a list for indexes to be removed. But, I don't exactly know how to fill that list correctly based on those check boxes.
Let's clear it. I use Dev Express Spreadsheet in my own project. I deliver the whole spreadsheet into a DataTable. I use those checkboxes (toggle check) as settings in my menu, not in every row. Those are just settings that the user sets before pressing the calculation button.
modified 2-Apr-21 0:12am.
|
|
|
|
|
I think you should scrap the whole thing and rethink your entire UI.
2000 rows, each with a variety of checkboxes?
How do you expect any user to actually use that? Did you even try it past the first page? How long do you think it's going to take to set up all the checkboxes ready to press the "delete" button, check that they have the right ones - and no wrong ones?
I have no idea what exactly you want to do, but I am pretty sure that that isn't the right idea.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Let's clear it. I use Dev Express Spreadsheet in my own project. I deliver the whole spreadsheet into a DataTable. I use those checkboxes (toggle check) as settings in my menu, not in every row. Those are just settings that the user sets before pressing the calculation button.
|
|
|
|
|
So presumably you and/or your users will never ever grow the business to the size where there will be 20,000 much less 20,000,000 entries in that list.
Typically what these solutions are when they do not support 20 million rows (or more) is that the check boxes only apply to the currently viewable page. If the you and your users want to go through 500 pages checking boxes then they can do it. But then one doesn't need to worry about how long it the UI will take to display, update and manage large numbers of rows. (And I am not suggesting that solution just noting it.)
|
|
|
|
|
I have done some solutions but it works correctly when I check just one checkbox. When I use more than one checkboxes for each column's contents, it deletes some rows unintentionally.
|
|
|
|
|
 My code may seem complicated but I try to give you some necessary parts. In this code, I delete rows based on duplicate contents of column E, from/to dates and toggle checkboxes checked:
int LastRow = my_table3.Rows.Count;
my_table3.Columns.Add("تاریخ");
my_table3.Rows[0][35] = "تاریخ";
for (int i = 1; i < LastRow; i++)
{
my_table3.Rows[i][35] = string.Join("/", my_table3.Rows[i][19], my_table3.Rows[i][20]);
}
var check_box = new List<string>();
foreach (BarItem c in ribbonControl1.Items)
{
if (c is BarToggleSwitchItem tg)
{
if (tg.Checked)
{
check_box.Add(tg.Description);
}
}
}
var valuesSeen = new HashSet<string>();
var duplicateRows = new List<int>();
column_select.EditValue = "E";
string selcolumn = (string)column_select.EditValue;
int column_index = worksheet.Columns[selcolumn].Index;
for (int i = 0; i < LastRow; i++)
{
string cellValue = my_table3.Rows[i][column_index].ToString();
if (valuesSeen.Add(cellValue) == false)
{
duplicateRows.Add(i);
}
}
for (int i = duplicateRows.Count - 1; i >= 0; i--)
{
int index = duplicateRows[i];
my_table3.Rows[index].Delete();
my_table3.AcceptChanges();
}
LastRow = my_table3.Rows.Count;
var ToDelete = new List<int>();
for (int i = 1; i < LastRow; i++)
{
string one = FromDate.EditValue.ToString();
string two = ToDate.EditValue.ToString();
string three = my_table3.Rows[i][35].ToString();
DateTime dOne = GetDate(one);
DateTime dTwo = GetDate(two);
DateTime dThree = GetDate(three);
bool answer = dThree >= dOne && dThree <= dTwo;
string cellValue = my_table3.Rows[i][10].ToString();
string cellvalue2 = my_table3.Rows[i][9].ToString();
for (int k = 0; k < check_box.Count; k++)
{
if (cellValue != "خاتمه یافته" || cellvalue2 != "تعمیراتی" || answer == false || my_table3.Rows[i][14].ToString() != check_box[k].ToString())
{
ToDelete.Add(i);
}
}
}
for (int i = ToDelete.Count - 1; i >= 0; i--)
{
int index = ToDelete[i];
my_table3.Rows[index].Delete();
my_table3.AcceptChanges();
}
modified 2-Apr-21 1:39am.
|
|
|
|
|
Design your form with the checkboxes set up as filters, allow the users to select any filter elements validating that a minimum are checked - 2000 row is ridiculous.
Have the data in the supporting .cs ready to be filtered but not displayed.
Add a go button to apply the filter, filter the underlying data into a list and bind the list to the UI grid and disable the go button.
Rinse and repeat if the user changes the filter conditions (when a checkbox in the filter is changed clear the list and enable the go button).
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
Let's clear it. I use Dev Express Spreadsheet in my own project. I deliver the whole spreadsheet into a DataTable. I use those checkboxes (toggle check) as settings in my menu, not in every row. Those are just settings that the user sets before pressing the calculation button.
|
|
|
|
|
Your menu and checkbox structure is fine - your treatment of the datatable is not.
Create a new datatable (or list) to store the rows to be displayed.
Loop each record in the source datatable (2k rows from the database)
check each of the criteria on the row
If the row passes the filter then add it to the display datatable or list.
DO NOT DELETE THE DATA FROM THE SOURCE DATATABLE or you need to go back to the database for each filter.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
You should be using radio buttons, not checkboxes; your options are mutually exclusive. Which also implies fewer fields. You have architectural issues.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
The user may need to filter West and East parts, for example. Thus, I have to provide toggle checkboxes.
|
|
|
|
|
In that case, use checkboxes.
So far, it would seem easier to create a new datatable by "filtering" the original; instead of compacting the original.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Hi all, I use a partial view in my net core MVC Web project ( personal project not work ) which receives a Model ViewButtonText
public class ViewButtonText
{
public string ButtonText { get; set; }
}
and the partial view is
@model Commands.Models.ViewButtonText
<input type="submit" name="submit" value=@Model.ButtonText>
<input type="submit" name="submit" value="Cancel" />
All works as expected until I set ButtonText to a value which has a space in it e.g. "My Button" which results in the text on the button only showing the first word - any idea why guys ?
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
|
|
|
|
|
@model Commands.Models.ViewButtonText
<input type="submit" name="submit" value="@Model.ButtonText">
<input type="submit" name="submit" value="Cancel" />
"Time flies like an arrow. Fruit flies like a banana."
|
|
|
|
|
Thanks Matthew
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
|
|
|
|
|
Hi,
Could you help with all possible ways of autoconnection of shapes dropped in WPS canvas?
We are assuming that:
1. Shapes have connectors/adorners
2. Shapes have in same layer
3. Second shape dragged from shapes library and brought close to first shape.
4. Next - happens autonnection of close to each other connectors.
The visual (only) reference can be seen (from 8m11sec) GERU Tutorial: Logic Flow & Email Messages - YouTube[^]
The main problem of using the option of constant comparison/calculation of connectors' distance will be done during the move of shapes.
And it will load the CPU as technically each/any movement of any shape (there can be dozen) in canvas will be calculated then heavily loading the CPU=slowing down the app...
Are there different ways or tips/tricks of doing it?
Ideally some sample of code if feasible?
Thanks a lot!
modified 31-Mar-21 13:35pm.
|
|
|
|
|
Visio doesn't "auto connect" ... they would have figured it out if it was wanted / practical.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Sure, Gerry. Thanks for your comment. I meant the "shapes library similar to Visio's".
To avoid the confusion I have deleted that part.
Thanks again
|
|
|
|
|
Visio requires one to drag and drop connectors, and join each end.
"Auto-connect" will encounter all the problems you identified.
If I was to improve on Visio:
1) Drag and drop shapes (already does this)
What it can't do:
2) Initiate a "connect" operation, using a given connector, and some "motion"
3) "Tap" connection points 1 (tail) and 2 (head)
4) Visio adds the connection, respecting the head and tail symbols, if present.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Thanks Gerry. But , again, there is No need of doing/improving/doing anything with Visio.
Just about ways to autoconnect shapes in WPF.
|
|
|
|
|
So, you're unable to take the references to Visio and relate them to your situation?
(I have no actual plans to "improve" Visio).
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Nope. I am trying to understand the ways it can be done from more skilled coders...
|
|
|
|
|
Hi, I'm trying to make a library where you can add books, search for books etc, I have a hardcoded book that you should be able to search for but it only displays the after I add a new book and then it will display the hardcoded book if you search for it again
the code
public class Book
{
public String BookName { get; set; }
public String AuthorName { get; set; }
public int NumberOfCopiesInStock { get; set; }
public String ISBN { get; set; }
public Book(String bookName, String authorName, int numberOfCopiesInStock, String isbn)
{
this.BookName = bookName;
this.AuthorName = authorName;
this.NumberOfCopiesInStock = numberOfCopiesInStock;
this.ISBN = isbn;
}
public override String ToString()
{
return ("BookName: " + BookName
+ "\n"
+ "Author Name: " + AuthorName
+ "\n"
+ "Number Of Copies: " + NumberOfCopiesInStock
+ "\n"
+ "ISBN: " + ISBN);
}
}
public class Search
{
public Boolean SearchForBook()
{
Console.WriteLine("Please enter name of book: ");
String search = Console.ReadLine();
UserInput.MakeTheComputerSleep();
foreach (Book b in UserInput.bookList)
{
if (b.BookName.Equals(search))
{
Console.WriteLine(b);
return true;
}
}
Console.WriteLine("Book doesn't exist! ");
return false;
}
}
<pre>public class UserInput
{
public static Boolean KeepGoing = true;
public static List<Book> bookList = new List<Book>();
private static readonly String INPUT_ERROR_MESSAGE = "Please only enter NUMBERS!";
private static readonly String INVALID_CHOICE = "INVALID CHOICE ENTERED!";
private static readonly String SEARCH_MESSAGE = "Searching for book,please wait......";
private static Random RandomObject = new Random();
public static void WelcomeMessage()
{
Console.WriteLine("********************");
Console.WriteLine("* Cork *");
Console.WriteLine("* Library *");
Console.WriteLine("********************");
}
private static void MenuHeader()
{
Console.WriteLine("********************");
Console.WriteLine("* Menu *");
Console.WriteLine("* Options *");
Console.WriteLine("********************");
}
private static void MenuOptions()
{
Console.WriteLine("1.) Add Book. ");
Console.WriteLine("2.) Search for Book. ");
Console.WriteLine("3.) Delete Book. ");
Console.WriteLine("4.) Display all Book. ");
Console.WriteLine("0.) Exit. ");
}
public static void GetUserInput()
{
int choice;
MenuHeader();
do
{
MenuOptions();
Console.WriteLine(">");
choice = 0;
while (!int.TryParse(Console.ReadLine(), out choice))
{
Console.WriteLine(INPUT_ERROR_MESSAGE);
}
PickChoice(choice);
} while (choice != 0);
}
private static void PickChoice(int choice)
{
switch (choice)
{
case 1:
AddBook addBook = new AddBook();
addBook.EnterBookInfo();
break;
case 2:
Search search = new Search();
search.SearchForBook();
break;
case 3:
break;
case 4:
AddBook addBook1 = new AddBook();
addBook1.PrintListOfBooks();
break;
case 0:
Exit exit = new Exit();
exit.Exit_Application();
break;
default:
Console.WriteLine(INVALID_CHOICE);
break;
}
}
public static void MakeTheComputerSleep()
{
int number = RandomObject.Next(10) + 1;
Console.WriteLine("Searching for Book.......");
Thread.Sleep(number * 1000);
}
}
public class AddBook
{
public void EnterBookInfo()
{
while (UserInput.KeepGoing)
{
Console.WriteLine("Please enter name of book: ");
String BookName = Console.ReadLine();
if (BookName.Equals("end"))
{
break;
}
Console.WriteLine("Please enter Author Name: ");
String AuthorName = Console.ReadLine();
Console.WriteLine("Please enter ISBN Number: ");
String ISBN = Console.ReadLine();
Console.WriteLine("Please enter number of books: ");
int NumberOfCopiesInStock = Convert.ToInt32(Console.ReadLine());
Book book1 = new Book("Neverwhere", "Neil Gaimen", 1, "aaaaa");
Book book = new Book(BookName, AuthorName, NumberOfCopiesInStock, ISBN);
UserInput.bookList.Add(book);
UserInput.bookList.Add(book1);
}
}
public void PrintListOfBooks()
{
foreach (Book b in UserInput.bookList)
{
Console.WriteLine(b.ToString());
Console.WriteLine();
}
}
}
class Program
{
public static void Main(string[] args)
{
UserInput.WelcomeMessage();
UserInput.GetUserInput();
}
}
any help at all would be appreciated , thanks.
|
|
|
|