i want to create a custom control (like UITableView in iPhone) in .Net using c sharp so user can scroll using mouse or keyboard navigation keys. I also want to create event when user click on any row. Currently the possible control is Datagridview which seems to me correct but i want to know the other possible approaches. So please suggest or advice other alternative
The DataGridView does sound like it might fit your simple requirements, you can certainly scroll using the mouse or keyboard. Also there is the CellMouseClick which is fired when the user clicks the grid. This reports row and column index.
However, the iPhone UITableView is not multi-column. If you do not heen a grid-like layout (rows and columns), then DataGridView is overkill. You might want to consider ListBox instead. This has a SelectedIndexChanged event which can be used to detect row clicks.
Related
I am working on a project in C# on the .net micro framework, using the GHI Glide graphical library. I need to navigate a DataGrid through the use of directional keys and a numeric keypad (and NO touchscreen). There is an enter button which I am using to activate what I call "Edit DataGrid Mode", where I call the following on the DataGrid myGrid (which selects row 10, for example, and colors it yellow): myGrid.SelectedIndex = 10;
Problem is, I would like to be able to enter into a "Edit Cell Mode" when I click the enter button again, but in the DataGrid class, there doesn't seem to be any way to show a cell is selected. I thought about using a popup window that would get the data from the cell and then proceed from there, but I would rather avoid popups in favor of a more streamlined approach.
Am I missing something about how I could trigger touch events to make a cell select? Or should I just go the hardcore route and use something similar to window.Graphics.DrawTextInRect(...); to make a text rectangle appear over the cell I am editing?
Change the selection unit property of the Datagrid. Selection Mode would be the alternative to your problem if selection unit is already on cell.
Thanks for your help, but I found that the GHI Glide graphical library for .net micro framework does not have this capability, and other ways of inputting data must be used (sorry for the confusion, there wasn't a tag for Glide). I ended up using a TextBox component to serve as a background and adding other components on top of it, setting the text of those components as I retrieved data from the table.
I want my ListBox to have columns, and one of those columns have to be a clickable URL.
How can I achieve this?
You can't do it in a ListBox. You can create your own control, or settle for another existing one. Based on the question, I'd guess you're not yet at the stage where you're creating your own controls. That takes a pretty good understanding of existing controls and the way they work under the covers (but a google search for creating Winforms Controls should yield plenty of instructions.) Edit added It looks like te 4th and 5th links in combination on that google search should get you what you need. You can create your own user control and then do an array of them)
As far as for other possible alternatives, have you considered a DataGridView? A DataGridView can have a hyperlink and it can have checkbox columns, so this would be one possible alternative.
Here's a link for having a Hyperlink column in a DataGridView.
Well, it is possible by using the CustomTabOffsets property (unreliable) or the DrawItem event. And implementing the MouseDown event to find out if that particular 'column' was clicked.
But there's little point, a ListView control with View = Details gives you the same functionality.
I'm working on a piece of code that I inherited and am trying to expand it from only being able to select one row to being able to select multiple rows.
Essentially, the item I'm working with displays like a data table. It contains methods for "OnSelectItem" and "OnMouseDown", with "OnMouseDown" checking to see if the click is right mouse button click or a left mouse button click.
Generally, how is functionality to support the ability to support Multi Select implemented? Is it handled through recognization of the mouse clicks in addition to holding down particular keys or is there a different way to implement this type of functionality?
Your comments indicate that you're working with a custom control. So, answers that apply to general Microsoft-supplied controls may not work at all.
You should be able to use the events you've listed already to handle multi-select features in this custom control.
As an example, you could look at the CheckedListBox control. It has a checkbox in front of every row. If the box is checked, that row is "selected". If that's not the type of selection you're looking for, then you can look at the ListView control in Detail mode. It allows you to set options that let the user highlight multiple rows, using CTRL and/or SHIFT to modify the way the mouse-click affects selection.
As far as multi select is concerned from my point of view it also requires key board support in addition to mouse click
1) In Controls if we press shift key and then press up or down arrow key then also row get selected
2) We can also implement multi select functionality by checkbox column, i am not sure this is possible or not in your case
3) There is also fundamental of Fixed Column, on mouse click of that column entire row is getting selectd
I'm trying to create a DataGridView cell class which hosts a control (all the time, not just while editing). So far, my approach has been to add the control to the grid and try to synchronise its position with that of the cell.
Would it be possible instead to keep the cell offscreen, route mouse and keyboard events to it, and paint it onto the cell?
UPDATE: By 'offscreen', I don't mean that it should be added to another control such that it isn't displayed; I mean that it should never be added to another control at all.
You can create a control without adding it to the form, then using it as the Cell editor whenever you need to. Usually with grids, when you click on a cell to edit it, it's going to either create a new control and put it in the right place, or it's going to use an existing control. You can make this process a lot easier by creating your own custom cell / column types. See this MSDN page: http://msdn.microsoft.com/en-us/library/7fb61s43.aspx.
Most grids (including DataGridView and 3rd Party Grids) have a facility for adding custom cells.
I have a Hierarchical gridview and I need implement the following functionality in the child gridview:
Show all the rows in editable mode (this can be done)
Save all data of each row on it's lost focus
We can capture the mouse events but how do we track the row lost focus triggered by the Keyboard. Ex: when a row is in focus, hitting f6 will go directly to browser address bar which results in the row lost focus event.
One mouse move across the rows will trigger all the validation and save logic for all the rows, this screen has hierarchical control and the child gridview has a minimum of 200 rows.
Any thoughts on how to implement this?
You'd probably need to implement a postback / callback when the blur event fires for the row on the client-side. I'm not exactly sure which DOM elements support the blur event in every browser but you can do it.
The GridEX control from Janus Systems can do it, but honestly, I'd really stay clear of doing things like Janus Systems do, so it's better you should find your own way.
EDIT: Try this.