|
|
Hello there
I've put dataGridView control on the Form and i've written this code:
private void Form1_Load(object sender, EventArgs e)<br />
{<br />
dataGridView1.Columns.Add("Main", "Main");<br />
dataGridView1.Rows.Add(3);<br />
<br />
dataGridView1[0, 0].Value = "A";<br />
dataGridView1[0, 1].Value = "B";<br />
dataGridView1[0, 2].Value = "F";<br />
dataGridView1[0, 3].Value = "ABC";<br />
}
So, when i try to sort it (clicking on the header of the table) - the last row ("ABC") is every time the last
You can go a long way with a smile. You can go a lot farther with a smile and a gun. (C) Al Capone
|
|
|
|
|
Hi,
Make number of row 1 more then acutal rows.
dataGridView1.Rows.Add(4)
I think internally it take the last rows as newRow and doesnot considers while sorting.
Hope this helps.
Regards,
Anil Ch
|
|
|
|
|
Hello everyone,
The Windows Application that I am working on requires displaying some data which are stored in a remote database server. The user can get connect and import the data into the application and then get disconnected and continue working. The Windows Application requires having similar ability to the database server as it needs to run queries on the Data.
I have tried the following approaches and ended up with some problems.
The first approach was to load the data into a DataGrid and then use filters on the DataSet to run queries. Unfortunately, I need to display the filtered data in different manner than DataGrid and I was unable to do so. I need to display the filtered data in number of TextBoxs and not in the DataGrid. Sadly, I was not able to do so unless I am missing something here!
The second approach was to download the data into a CSV file and then use combination of StreamReader and StreamWriter to run query on the CSV file and achieve what is needed. Sadly, the speed that I can run query is very much dependent on the size of the CSV file. Unless I am missing something here too!
My question is, what is the best way to import data from a remote database server and have the ability to run query and display the result in a fashion that I desire (in various TextBox)?
Thank you very much and have a great day.
Khoramdin
|
|
|
|
|
Do you need to have the data imported from SQL server accessable only in the active session or have them for later processing too?
In first case you can store the data in a DataTable object (in memory), apply filters on it and take out any data from the Rows[ItemNo] object to feel your TextBoxes.
In the second case you can establish connection to some local data store like FoxPro dbf files or Access mdb, store your data there and then use all index search advantages to execute your tasks.
Tell me, why do you need to process data offline?
|
|
|
|
|
the code of Ant on a Chessboard please...
|
|
|
|
|
Write it yourself, or Google for it. All you have to do is type "ant on a chessboard" into the search box.
If you wanted help writing it yourself, ask specific questions about where you're getting stuck. Just comming here asking for the code will only be met by replies with a flamethrower.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Sorry, I don't have it lying around, but I have the code for Troll in a Forum
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
what does this mean - "Black holes are the places where God divided by 0..." ??
Blumen
|
|
|
|
|
M.omar wrote: the code of Ant on a Chessboard please...
Don't have that but here is the code for Loser on a Forum
static public class FlameThrower<br />
{<br />
public static void throwflames()<br />
{<br />
Console.WriteLine("LOSER");<br />
}<br />
}<br />
led mike
|
|
|
|
|
|
Hey guys,
Im in the process of creating a 1941-type shooter set in outer space. I have a simple jpeg of distant stars I wanted to set as the background. How can achieve this? And if possible, how can I make it scroll as if my spaceship appears to be moving?
Thanks for any help.
|
|
|
|
|
That's going to be a problem. A scrolling background on a Windows form means that the background will be redrawing every time the image scrolls even one pixel. That will also force a redraw of every control on the form. The more controls you have, the more time it takes to generate a single frame in your game.
The best solution you have is to use DirectX. But, that would require a complete rewrite of your game. You might want to look into Microsoft's XNA Developer's Center[^] first.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
In 2D Games with the tpye you want:
1) There is a screen size background image and you draw onto a part of this big background image and update(Invalidate) just that part so because the user does see only a small portion of the big background image, he thinks he is moving in some directions
2) Have a look at Code4Fun web site, where you can find some tutorials on game development.
Hope this helps...
|
|
|
|
|
I want to allow users to create filters by typing in a textbox the filter they wish to apply to any particular column. I want to apply the filter as the user types it, and I want to apply it as if the displayed value were a string. For example, if I have data with numbers 0-23 associated with it, and a user types the number 1, all data with numbers 1 or 10-19 should still be displayed. So essentially, I want to apply the filter expression "[ID] LIKE '1%'", but when I do this I get the error "Cannot perform 'Like' operation on System.Int64 and System.String". How can I prevent this error without making the filter string something like "[ID] = 1 OR ([ID] >= 10 AND [ID] < 20) OR ([ID] >= 100 AND [ID] < 200) OR ..." (because that would get out of hand)? (I also posted this in ADO because I don't really know where it belongs) Thanks.
-Jeff
|
|
|
|
|
What's the data source you're using? If it's not a database souce, like an Access or SQL database, you can't do filtering. Filtering does not work on every data source, like arrays or lists. You can check the SupportsFiltering property of your BindingSource object to see if the datasource supports filtering.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Its a database. The same code works if the type of column ID is string.
-Jeff
|
|
|
|
|
OK. Well, you can't do a LIKE on a number, not even in SQL. If you were to allow LIKE operations on any field, you'd have to retrieve the data from the database, having it convert all the numeric fields to strings before they get sent to your DataSet. THEN, you can do a LIKE filter on it.
Of course, the problem becomes writing that data back to the database if there are any changes to it. You'd have to have a stored procedure convert the "string" data back to their appropriate data types in the INSET and UPDATE queries.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
i am kind of new to C#, i was wondering if there is a way to find how much is there "red" "blue" and "green" in an image? is there any method for that ?
Thx
Iceman
|
|
|
|
|
icecool_56 wrote: if there is a way to find how much is there "red" "blue" and "green" in an image? is there any method for that ?
Only if you write it. There's nothing in the .NET BCL that will do this for you. Search the articles for "image processing per pixel filters" and you'll find a string of articles by Christian Graus that you can use to built your own method quite easily.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
|
Hi Friends,
I have a requirement for the DataGridView of Windows Forms and is explained as follows:
1. I have a Quantity textbox in the DataGridView.
2. When the user enter the quantity > 1 (say 3), a total of 3 rows should
be added including the current row with the row quantity in all the rows as 1.
3. This should be achieved only when the user hits the Enter key in the
current cell.
4. If the row where the quantity being modified is in the middle of the grid, the rows next to the current row should get re-positioned based on the number of new rows added.
eg:
ProductDesc Qty (TextBox)<br />
Compaq Laptop 3 <br />
DELL DesktopPC 1
When Enter key is pressed in the quantity textbox (for the product Compaq Laptop), the output in the grid should be as follows:
ProductDesc Qty (TextBox)<br />
Compaq Laptop 1 <br />
Compaq Laptop 1<br />
Compaq Laptop 1<br />
DELL DesktopPC 1
I have tried with a couple of existing events of the DataGridView but I couldn't achieve.
Please help me with some suggestions.
Thanks.
Subrahmanyam K
|
|
|
|
|
Most likely, your DataGridView has a DataTable as data source. In this case you have to only add 3 rows in the DataTable. Rows in the DataGridView will appear automatically.
|
|
|
|
|
If your DataGridView is not databound, DataSource = null in this case, then you can use:
DataGridViewRowCollection.Add (Object[]) like:
myDGV.Row.Add(new object[] {"Compaq Laptop", 1});
myDGV.Row.Add(new object[] {"Dell DesktopPC", 1});
BUT, before, be sure that your myDGV has 2 columns with appropriate typers to hold and display your values.
|
|
|
|
|
Please don't cross post in multiple forums. I already answered in the General Discussions forum.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|