|
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.
|
|
|
|
|
This would be EASILY found running the code under the debugger.
Look at the flow of your code, specifically when you call EnterBookInfo AND where you put the "hardcoded" books to get added. So, yeah, those books won't get added until you call, and wait for, user input.
You're program structure is a bit messed up. You should NOT have a class called "AddBook". That should be a method on a collection class called Books. Typically, if you have a name that starts with a verb, "Add", it should be a method in a class. Nouns should be classes, like "Book" or "Books".
"Search" should also be a method of the Books class. Both methods should NOT be prompting or handling user input.
"PrintListOfBooks" should also be a method of a Books class.
Your "UserInput" class, while OK, is a bit misplaced. You should be expanding it a bit to handle all prompting and user input for all menu options.
|
|
|
|
|
I did some messing around and I added a method called AddBooks(); with the hardcoded books and then I added method calls within the switch statment to that method and it now seems to work the way I want it too
<pre>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();
AddBook();
break;
case 3:
break;
case 4:
AddBook addBook1 = new AddBook();
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 static void AddBook()
{
Book book1 = new Book("Neverwhere", "Neil Gaimen", 1, "aaaaa");
bookList.Add(book1);
}
I don't think this is the most optimal way though?
|
|
|
|
|
It'll work. But for "optimal", you'd have to scrap your entire code and start from scratch, except for the Book class. That's about the only thing you've got going that's correct for "optimal".
|
|
|
|
|
Thanks for posting dave, I'll scrap everything and start over and try again.
|
|
|
|
|
I have a DataTable which all of its columns are in string format. But some columns have only numeric values and I want to convert them into numbers so I can do numeric calculations over them. I used this code but it gives runtime error:
int cellvalue3 = int.Parse(my_table3.Rows[i][19].ToString());
The error is on this line and says:
System.FormatException: 'Input string was not in a correct format.'
How can I fix this issue?
|
|
|
|
|
At least one row has a value in column 20 which is not numeric. You need to debug your code and examine the value that's causing the problem to see why it's not the value you're expecting.
If your column could contain a mixture of numeric and non-numeric values, and you only want to process the numeric values, use int.TryParse instead:
Int32.TryParse Method (System) | Microsoft Docs[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
dont forget a comma is not numeric
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
int cellvalue3 = !string.IsNullOrEmpty(Convert.ToString(my_table3.Rows[i][19])) ? Convert.ToInt32(my_table3.Rows[i][19]) : 0;
|
|
|
|
|
That won't cope with non-empty non-numeric strings. What if the cell contains "Foo" ?
Use TryParse[^] instead.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|