Hello, I am having a little trouble with using the windows forms datagrid control. In my program, I need to give the user the ability to select and unselect multiple rows in the datagrid and then perform some action on those selected rows. Initially, I was hoping to use checkboxes. I made a bool column in my database and added a checkbox column in my datagrid. This appeared to work okay. When I wanted to determine the selected rows, I just iterated through my data table and looked at the value of the column that was bound to the checkbox column. However, I soon found a problem with this approach. I have a "Select" menu, with different options that select thousands of rows in the datagrid (such as select all, select none, etc.) In order to do this, I needed to change the value of many checkboxes at once, and this is very very slow because I am having to edit each row in the corresponding datatable. I've been trying to figure out other ways to get the same functionality, and I thought that maybe I could just use the built-in select in the datagrid (highlighting the entire row). I was able to select large numbers of rows much more quickly this way because I wasn't modifying any data in the datatable. However, now I have another problem. I don't know how to relate a row in the datagrid to the correct row in the datatable. I've found some code examples such as this: BindingManagerBase bm = dataGrid1.BindingContext[dataGrid1.DataSource,dataGrid1.DataMember]; DataRow dr = ((DataRowView)bm.Current).Row; But, this only works for the current row. What if I have a list of the row indexes in the datagrid, and I want to iterate through that list and perform actions on the correct row in the datatable? Also, I really prefer the checkboxes over the highlighted rows. Is there a way that I can implement checkboxes without having to make a column in my datatable? Any ideas would be great! Thanks, Blake
blakeb_1
Posts
-
Relating datagrid rows to datatable rows -
Unbound checkbox column in datagridHello, I am trying to implement a checkbox column in a datagrid that will provide the user the ability of checking certain rows that they want to perform some action on. Here is my problem. Originally, I just added a new row in my database called "Checked". This seemed to be working okay until I started trying to implement a "Select All" functionality. In order to do this, I have to loop through each row in my datatable and set the value for the "Checked" column to true. This takes forever because there are 13,000 rows in the table. My question is this: is there any way to add a column to a datagrid without having it bound to a column in the datatable? What other options are there for doing something like this? I guess I could just use the regular select functionality of the datagrid, but this requires the user to hold down control to select multiple rows. Any ideas? Thanks, Blake
-
Max length of text in statusbar?The statusbar only displays the first 127 characters of the text string. To get around this, I made an owner-drawn panel, and used DrawString to draw the text.
-
Max length of text in statusbar?Nevermind, I found the answer. Guess I'll have to use a custom statusbar component or make my own.
-
Max length of text in statusbar?Hello, Is there a max length of text that can be shown in the statusbar? I can only get it to hold 127 characters in the statusbar or in a statusbar panel. Blake
-
access rows in order that they appear after sorting datagridThanks!!
-
access rows in order that they appear after sorting datagridHello, I am trying to print out a datagrid, and I have code that works fine, but it won't print the data in sorted order if it has been sorted in the datagrid. It still prints the original order. How can I access the rows in sorted order instead of in the original order? theTable.Rows[i] is what I've been using to loop through the rows, but is there anything else I can use so that I can print the grid sorted. Thanks, Blake
-
Problems with Sandbox ModeHello, I have a question about querying an Access database from a .Net program. I am using C#. What I want to be able to do is use the instrrev() function in an sql query to find the first period from the right of a string (to get the extension from and e-mail address). However, anytime i try to use instrrev I get an error saying that instrrev is an unknown function. I don't get this error when I use instr(). I researched on the internet and decided that this must be caused by the sandbox mode in the jet engine, so I turned sandbox mode off in Access. However, I still the get the same error when running the query from my C# program. Does anyone know how I can use this function, or is there any other way to solve my problem? I thought about using strreverse() and the using instr(), but it turns out that strreverse() is another function that won't work. Any help is appreciated. Thanks! Blake
-
getting MX servers for mail validationHello, I'm trying to implement an e-mail validation program for a large mailing list, and I've run into a few problems. So far, I have code that correctly checks all the syntaxes, and I have code that will check if an address is valid when it is given a list of mail exchanges, however, I can't get my code that actually retrieves the MX servers to work. Does anyone have any code for MX lookup? I found the code I'm currently using at: http://groups.google.com/groups?selm=eMOLVL2WDHA.652%40tk2msftngp13.phx.gbl&oe=UTF-8&output=gplain I can't tell if there is something wrong with the code or if I am just not using it correctly. Here is how I am trying to intialize the DnsLite class:
ArrayList mxRecords = new ArrayList(); //hostname is the domain, such as hotmail.com IPHostEntry IPhst = Dns.Resolve(hostname); DnsLib.DnsLite dnsStruct = new DnsLib.DnsLite(); ArrayList dnsList = new ArrayList(); for(int j = 0; j < IPhst.AddressList.Length; j++) { dnsList.Add(IPhst.AddressList[j].ToString()); } dnsStruct.setDnsServers(dnsList); mxRecords = dnsStruct.getMXRecords(hostname);
This doesn't seem to be working correctly. Does anyone know if this code looks like it should work, or if there is better code examples of MX lookups anywhere that I look at. Thanks, Blake -
E-mail Validation to clean-up mailing listsCan I use that mx validator component in a C# program?
-
E-mail Validation to clean-up mailing listsTroy, Actually, I've just realized that this isn't going to work because the mailing list program we are using isn't going to allow to do any extra programming. I think I might just stick to verifying through the smtp servers for now, and hopefully it will at least cut down on a little of the bounces. Thanks for offering to send some code though. Blake
-
E-mail Validation to clean-up mailing listsTroy, This is exactly what I have been thinking about doing (I read an article about it on this website), and I thought that I might even combine it with the MX checking that other people had posted about. I would love to see some details and code if you want to send it to me. Maybe I can figure out a way to make it work for our purposes. You can send it to blakeb_1@hotmail.com Thanks a lot Blake
-
E-mail Validation to clean-up mailing listsHello, I am interested in creating a program to handle large a mailing list and help eliminated bounced messages by doing e-mail validation. I've looked at articles on this site and elsewhere on the web, and it appears that most of the validation approaches include validating the e-mail address syntax with regular expressions, then validating that the domain exists, then connecting to the smtp server and making sure that it will accept mail for a certain address. However, I have read that this will not work for some e-mail providers, such as aol, hotmail, servers based on ms outlook, etc. and that the only way to find out if an e-mail address is really valid for these is to wait and see if the message bounces back. Does anyone know of a sure way to validate all e-mail addresses, or is it just not possible? I guess if there is no 100% correct way, then I can try to combine the two approaches by first checking addresses by contacting the smtp server, and then also analyzing bounced messages. Thanks for any input. Blake
-
How to make print preview maximized?I did the WindowState equal to Maximized and its working. Thanks! I just figured since it wasn't in the code editor that it wouldn't work. Blake
-
How to make print preview maximized?I tried that, but the problem is that it doesn't change the state at all, so the maximize button is still available for clicking. Also, it doesn't seem to position the window correctly either. It makes it the correct size, but it doesn't position at the top of the screen. Is there no possible way to actually change the maximized state and not just the size? Thanks, Blake
-
How to make print preview maximized?Does anyone know how to make the print preview dialog open up in a maximized state? It doesn't have a WindowState property, so I'm not really sure what to do. Thanks, Blake
-
highlighting text in a combo box with the mouseOkay, thanks! Blake
-
highlighting text in a combo box with the mouseHello, Is there any way to work around the .Net bug that doesn't allow text in a combobox to be highlighted with the mouse? This seems like something that any combobox should allow. Thanks, Blake
-
clicking "Open with" when multiple files are selectedYes, you're correct. I was using the menu entry instead of "Open with" and I had just assumed that Textpad would work the same way when using open with as it does with it's menu entry. But apparently not. I guess now my question would be how to make a shell entry that would work like that. Any tips on how to go about finding out what files are selected? Thanks, Blake
-
Saving application optionsHello, I'm trying to decide what is the best way to store my application's location, size, state and also a bunch of other options such as font, color, recently viewed files, etc. Should I store the information in the registry or in some type of a file? Do people still use .ini files for saving settings anymore? In an older version of my application, I stored the information in a .ini file, but I'm not sure if that is the best way to do it. Thanks in advance, Blake