C# :: Listbox File Populate Filtered With Regex

Sep 27, 2014

i found somewhere online this code that populate my listbox with file names. Now is it anyhow possible to filter those names before it gets populated by regex ?

Code:

private void PopulateListBox(ListBox lsb, string Folder, string FileType)
{
DirectoryInfo dinfo = new DirectoryInfo(Folder);
FileInfo[] Files = dinfo.GetFiles(FileType);
foreach (FileInfo file in Files)
{
lsb.Items.Add(file.Name);
}
}

Call on form load:

PopulateListBox(listBox1, Application.StartupPath, "*.exe");

Now is there way to add regex for filename?

View 5 Replies


ADVERTISEMENT

C++ :: Create File With Given Size And Then Randomly Access File To Populate It

Feb 17, 2015

I am interested in creating a file of a given size and then randomly accessing the file to populate it. Is there a way to quickly create, for instance, a 4 GByte file in C++, initially populated with garbage?

View 4 Replies View Related

C# :: Populate ComboBox From Txt File

Sep 12, 2014

I am trying to fill a combobox using the data from a txt file, with the new line as a split.

Currently it is throwing a System.ArgumentException in mscorlib.dll

try {
string[] lineOfContents = File.ReadAllLines(Properties.Resources.departments_list);
foreach (var line in lineOfContents) {
string[] tokens = line.Split('

[Code]...

My txt list is a resource in my project.

Accounts,
Power,
Commercial,
Procurement,
HumanResources,
Plant,
IT,
Reinstatement,
HealthSafety

why this is throwing the exception?

View 8 Replies View Related

C# :: Moving Listbox Selection To New Listbox In New Form?

Sep 11, 2014

Okay so i have everything right accept transfering the selectedindex from listbox in form1 to listbox in form2. I am using the below string item to hold the selected line of the list box, with the intent of recalling and then adding it into the form2 listbox. I get a not implemented error and i can't figure out why. I know the information is moving with the variable item, it just doesn't get printed out to the new listbox.

private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
string item = listBox1.SelectedItem.ToString();
Form2 form2 = new Form2();
form2.Show(item.ToString());

[Code]....

View 13 Replies View Related

C++ :: Performing RegEx On Open File

Jan 11, 2013

I'm trying to open a file and perform a regex on it, then print the matches, but I'm not sure if I have it right. I think I need to remove the line -

Code:
[for ( std::vector<TCHAR>::iterator It = buffer.begin();It != buffer.end(); It++ )

since I've already copied the file into the buffer, but how do I search the buffer?

Code:
std::ifstream in(TempFullPath, std::ios::in|std::ios::binary);
if( in.fail() )
{
std::cout << "File does not exist or could not open file";
}

[Code]....

View 1 Replies View Related

C Sharp :: Regex Pattern That Takes Only Directory Without File Name

Dec 5, 2014

regex pattern that takes only directory without file name
private void txtDownloadRoot_Validating(object sender, CancelEventArgs e)
{
Regex driveCheck = new Regex(@"([a-zA-Z]:[^/:*;/:?<>|]+)|({2}[^/:*;/:?<>|]+)");
if (!driveCheck.IsMatch(txtDownloadRoot.Text))

[Code].....

View 1 Replies View Related

C# :: How To Save Text From Listbox To The Txt File

Apr 19, 2014

I tried to save some data from my listbox to the text file, but didn't work... I think I tried many combination for code but still didn't work. what to do?

FileStream fs = new FileStream("tx.txt", FileMode.Create);
StreamWriter sr = new StreamWriter(fs);
sr.Write(listBox1.Text); //there is that problem, but I'm not sure how to write for success
sr.Close();

View 4 Replies View Related

C++ :: Saving Listbox Items Into Text File

Jan 17, 2013

The process cannot access the file because it is being used by another process.

How can i edit CStdioFile to let me open the file while the program is running.

View 2 Replies View Related

C Sharp :: Listbox Item Display - How To Add Column From File To Combobox

Oct 4, 2012

How to display the item in listbox,which are selected from three combobox.

View 1 Replies View Related

C# :: Populate Datagrid In WPF

Apr 3, 2015

I am trying to get a datagrid working in my program with populating a simple set of data. Which i can then expand on and bring in data from a database.

But even this little simple test datagrid does not seems to be working.

XAML Code

<DataGrid Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="2" Margin="10" Name="DataGrid_1" ItemsSource="{Binding DataGridData}"></DataGrid>
<Button Grid.Row="6" Grid.Column="2" Margin="10" FontSize="12" Command="{Binding Path=GetDataGridData_Command}">Get Data</Button>

[Code].....

View 3 Replies View Related

C# :: Populate Data In Datagrid?

Mar 29, 2014

im trying to populate a datagrid, i have a datbase class

public static List<Product> LoadProduct()
{
....................
}

i have a product class

gettor & settors
public Product(int id, string Name, double Price, int Quantity)
{
productId = id;
productName = Name;
productUnitPrice = Price;
productQuantity = Quantity;
}

ive added the HTML code to set up the datagrid, which i can see via design tab, but filling it up is harder.

i uderstand it needs a

protected System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
sqlDataAdapter1.Fill();// where it require a dataset or datatable
DataGridProduct.DataBind();

as it requires a datatable i converted the list to a datatable when i run it it says null, im not sure where im going wrong, i noe the list works as i tried populating on a table.

public static DataTable ToDataTable<T>(List<T> items)
{
}

View 1 Replies View Related

C# :: Populate Labels With A List Or Array?

Jun 9, 2014

I have a WPF grid made out of labels with two rows, Apples and Oranges currently without any information. Let's say I want to populate the grid to look like the picture below.

I was wondering what's the best way to populate the labels with a list or array? I was thinking about using a list and passing values into the list

E.g.

List <string> ApplesList = new List<string>();
ApplesList.Add("Red");
ApplesList.Add("Delicious"):

List<string> OrangesList = new List<string>();
OrangesList.Add("Orange");

etc...

But I was wondering it make sense to use a list. Or should I just use an array or 2D array?

Sometimes I wonder when would be best to use a list, array, or 2D array.

View 8 Replies View Related

C# :: How To Populate HTML TextBoxes With SQL Results

Mar 9, 2015

I have an HTML5 form with a number of text boxes on it. I would like these textboxes populating with data retreived from an SQL database, using inline C#. I have a stored procedure that returns the data.

View 8 Replies View Related

C++ :: Convert Integer To String And Populate Array?

Sep 4, 2013

// prompts the user for a non-negative numbers (>= 0)
// reads in the a number and checks
// keeps re-prompting user if the input is invalid (negative)

[Code].....

How do I go about Populating the elements in the array created, I keep getting a compiler error on this vArr[i] = tmp_stream.str.at(i);

View 1 Replies View Related

C# :: Linq To XML - Populate List With Multiple Values?

Aug 26, 2014

I have an XML document, formatted as such:

<?xml version="1.0" encoding="UTF-8"?>
<Books>
<Bookmark Name="1984" Folder="C:UsersmillerDownloads1984 (George Orwell) - Audio Book" Time="00:43:58.4080000" Chapter="0" />
</Books>

Each Element named Bookmark has 4 attributes, Name, Folder, Time, and Chapter.

I'd like to be able to just put all of them in ONE type of container, without making multiple lists... Is there any way, using Linq to XML, to maybe add all of these values to a Tuple?

View 14 Replies View Related

C# :: Populate Textboxes And ComboBoxes Through Data Grid View?

Dec 23, 2011

i m working on a simple project, i want to populate my text boxes and comboBoxes through DataGridView, means when i double click on cell content then the text boxes are populated.my question is that if i have to populate comboBox with the specific value then what i have to do then because comboBox.selectedItem is an object but my class property is a string..

e.g
combobox shows 30 days in it and my class is Code: class account
{
public string day{set;get}

[Code]....

but that does not happen because "comboBox.selectedItem" is an object so if i have to do that what i have to do then?

View 3 Replies View Related

C# :: Unable To Populate ComboBox From Observable Collection (String)

Mar 15, 2015

I have a window in WPF which I want the user to use to enter the information for a COM Port.

The intent is to populate two ComboBoxs from a two different ObservableCollection<string> which I am having no luck with.

I don't think that it is a DataContext issue, as I am able to get something from the ComRateList when the window opens, but nothing from BaudRateList. Either way I have included the way that the window is opened and DataContexts assigned...

When the code runs, the COM Port list is updated when the window opens - However, it is not updated when the user reclicks the ComboBox which was my intended behavour.

All the adds for the BaudRateList do not populate the ComboBox for the baud rates on start up, nor when the code is running.

When I step through the code, I can see all of the BaudRateList items being added... The window is called by the main window's datasource like so...

OpenSerialCommunication OpenView = new OpenSerialCommunication();
OpenView.Show();

This opens fine.

The OpenSerialCommunication.xaml is as follows: (Note that any business names have been replaced with [snip])

<Window x:Class="[snip].SerialCommunication.OpenSerialCommunication"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:serial="clr-namespace:[snip].SerialCommunication"
Title="Open COM Port - [snip]" Height="300" Width="300">
<Grid>

[Code] ....

View 1 Replies View Related

C Sharp :: How To Populate A Combobox With One Field Of Database Table

Apr 17, 2012

I would like to fill a combobox with particular field for example if i have atable with fields such as CustID, CustName, CustAge.

I would like to only fill the combobox with the Name filed such that only the CustNames will be field in the combobox and am able to write an event handler for the selected index.

View 1 Replies View Related

Visual C++ :: Get Streamreader To Read And Calculations To Populate Textbox

Jul 27, 2013

Here what i have so far, the error in the stream

[CODE]

Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim fileName As String = IO.File.ReadAllText("Grades.txt")
Dim GPA As Double = 0

[Code]....

View 1 Replies View Related

C++ :: How To Use Regex Library To Use It In CLI Game

Jan 18, 2015

I want to use C++ regex library, to use it in my lil' CLI game. The aim is to create the template(not C++ template :)) for command(like "go north"). Then, if player writes anything that contains "go", and "north" appearing after that(examples: "go north" "please go north" "Let's go north!" "Princess, I insist that we go to the north") would all be interpreted as simple "go north". I have used a bit of regex in Linux system, but not this ECMAScript regex that C++ uses.I've checked in some online regex tester, that if I write: ".*go.*north.*" then anything I want will be matched; however, I'd like these to be specifically separated by space(the rule is: between north and go there must be at least one character: a space, so that gornorth won't be interpreted as command.).

Bonus points: if it's possible to do that without some kind of black magic, I'd like to achieve following goals:

1)Before go, there can be any amount of characters, but if there is 1 or more characters, the character just before go must be space.
2)In between go and north, there must be at least one character, space. If there are more, then characters right after go and just before north have to be spaces.

View 8 Replies View Related

C++ :: Searching A MultiMap With Regex

Apr 24, 2014

I have a multimap with over 300k entries defined like so: std::multimap<std::string, std::string> filedata;

Using the following code and std::multimap::equal_range, I am able to successfully search for a word in the multimap and get needed data:

// Data with strings.
data = std::vector<std::string>();
// Get iterators to matched pairs.
std::pair <std::multimap<std::string, std::string>::iterator, std::multimap<std::string, std::string>::iterator> dat = filedata.equal_range(word);
// Go through each matched pair and get needed info.
for (std::multimap<std::string, std::string>::iterator iter = dat.first; iter != dat.second; iter++) {
data.push_back(iter->second);
}

Now, I would like to search the multimap using regular expressions (EX: std::regex("[a-z][a-e]h")). What is the fastest way to do this? Example code may look like:

std::pair <std::multimap<std::string, std::string>::iterator, std::multimap<std::string, std::string>::iterator> dat = filedata.equal_range_with_regex(std::regex("" + word + ""));. Pseudo-code / algorithms will be enough.

View 2 Replies View Related

C/C++ :: Regex - Get Word With Separator

Nov 23, 2014

string skirt = "[\s,.;:!?()\-]+";
regex re(skirt);
sregex_token_iterator it(begin(), end(), re, -1);
sregex_token_iterator reg_end;
for(; it != reg_end; ++it) {
string zodis = it->str();
}
}

I use this to get a word from a large text file. But the problem is, if there is :

however,
It prints out now
however,
but
however
without a separator.

How can I fix that?

View 12 Replies View Related

C# :: Split String With Regex

Aug 27, 2014

I have the the following two strings:

D 1069 Dresden - Neustadt
01069 Dresden - Neustadt

I want to splitt the string and the result should be in both cases:

1069
Dresden - Neustadt

How could i do this with regular expression?

View 6 Replies View Related

C++ :: Use Boost / Regex For Regular Expressions?

Sep 5, 2013

So I need to use boost/regex for regular expressions. someone told me that it needs to be built. the first problem is boost doesn't tell you how to build it and the second is i did sudo apt-get install libboost something. I don't remember the exact name of the package. it installed but i dont know how i would build it when its installed.

View 2 Replies View Related

C++ :: Create Map Containing Regex As Key And Char As Attribute

Mar 27, 2013

I want to create a map contaning a regex as key and a char* as an attribute , like:-

map<regex, char*> res;
res["[[:alnum:]]"] = "alphanumeric text";

but the following error is generated:-

vector<pair<regex,string>>res;
res.push_back(make_pair("[[:alnum:]]","alphanumeric"));

but the error generated is:-

no instance of overloaded function "std::vector<_Ty, _Alloc>::push_back [with _Ty=std::pair<std::regex, std::string>, _Alloc=std::allocator<std::pair<std::regex, std::string>>]" matches the argument list
argument types are: (std::pair<const char *, const char *>)
object type is: std::vector<std::pair<std::regex, std::string>, std::allocator<std::pair<std::regex, std::string>>>

View 13 Replies View Related

C++ :: STL Regex Get Position Of Match Within String

Apr 18, 2013

I am trying to get the position of the matches of "Un" in string "Unseen University" in c++ code using STL regex. How can I do this.

i.e. I have following:

std::vector<std::cmatch*>* matches = new std::vector<std::cmatch*>*;
intMyReturnVal = regex("Unseen University", "Un", matches);

I can access a match by

matches->at(i)

and get an Iterator to the beginning of the match by

matches->at(i)->begin()

How can I get the relative position of the match within the entire target string (i.e. "Unseen University", where, in this case, the positions should be 0 and 7)??

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved