I am working on a project in VB.Net, and am using a Table Layout Panel to allow for multiple windows to be open side by side with one another.
The issue I am dealing with right now is figuring out exactly which Column of the Table Layout Panel components are placed in at run time.
For example, let's say I have two Windows open, with 3 Columns. So there are controls in Columns 1 & 2, and Column 3 is empty. If I close the Window in Column 1, I want to detect the Column it was in, so that I can shift the Window in Column 2 over to Column 1. I'm trying to do this so I can resize the windows based on how many windows are being opened side by side.
However I can't seem to find a way to determine exactly while Column is the 'parent' Column. The parent container is the Table Layout Panel itself, but I don't know how to get the information I am looking for.
You can determine the position of a child control inside a TableLayoutPanel using its GetPositionFromControl() method, which will return a TableLayoutPanelCellPosition structure, identifying the Column and Row of the cell that a control is occupying:
Dim Position As TableLayoutPanelCellPosition =
TableLayoutPanel1.GetPositionFromControl([ControlName])
Position reports Position.Column and Position.Row as Integer values.
You can also detemine which child control is occupying a specified position, using the GetControlFromPosition() method:
Dim MyControl As Control = TableLayoutPanel1.GetControlFromPosition(0, 0)
Related
My application shall allow the user to look at a table (aka "map") 14 x 28 with X and Y axis loaded from a microcontroller (MCU). This can be edited and sent back into microcontroller. I have two arrays that contain the GUI map and MCU map, which allows any differences to be flagged.
I have a DataGridView that displays the data. This works with initial data. I simply can't get new data to be updated into the DataGridView. The DataGridView is in a Form within an Mdi Child. Here's how I command the changes:
'CalDataTable is the DataGridView
'Map is an array of Single
CalDataTable.Rows.Clear()
CalDataTable.Columns.Clear()
For j As Integer = 1 To 16 'Loop through data and populate table
For i As Integer = 1 To 24
CalDataTable.Rows(j).Cells(i).Value = Map(i - 1, j - 1)
Next
Next
This event is launched from a click in the menuStrip of the Mdi Parent, and the data does not update. However, when I launch the update through a button event within the MDI Child form, it works like a charm.
Am I using the wrong tool or what else could I be missing?
Calling .Rows.Clear() and .Columns.Clear() does more work than just emptying the data. It actually removes the rows and columns from the grid. There are no longer any cells in the grid at all. You don't want that. This isn't like Excel, where the workspace is still there even when you delete things. You need the column definitions and row records to still exist.
Instead, loop through and reset each cell to an empty value, whether that's 0, an empty string, or something else. Or, since it looks like the following loop will visit every cell anyway, just remove the Clear() lines completely.
is it possible to create listbox with multiple checkboxes in one row (Excel VBA)?
Thanks
Kamil
I'm not sure I understood your question fully, but I'll elaborate on ListBoxes as much as I can.
First things first: Checkboxes and ListBoxes are different objects in Excel Userforms. The first is the little box that returns a "true/false". The second is a list of items which can be chosen. Clicking in a Checkbox will make the tick mark appear/disappear (or fade if tristate is enabled), while clicking a Listbox row will turn the listbox row "blue"/"white" (or whatever color is being used for the selected rows). In both elements, clicking is a way to toggle between True and False.
While a checkbox only allows for a single information to be marked as True or False, a Listbox allows you to select entries out of a list. That list may be inserted through code (.AddItem method) or passed from a range (.RowSource property)
ListBox objects allow for multiple columns of data to be attributed to one row element, but each row is an entire element (which means you cannot pick the element on row 3, column 2 - only all of row 3). The number of columns is established using the ColumnCount property.
By changing the value of the MultiSelect property, you'll allow the user to select multiple or single row elements simultaneously on your Listbox. Using the Selected( RowIndex ) property, you can check whether or not an item is currently selected (returns True/False). Remember that row indexes start at 0.
Finally, if you're using the MultiSelect property set to fmMultiSelectSingle and have a single column (as far as I know), the Text property can be used to return the selected item's value.
An easy example of a listbox is in Excel can be found at File > Options > Customize Ribbon (or something like that). There are two listboxes, one (on the left) with the visible items and another with the available items. A pair of command buttons is used to move items between boxes. That's a simple application you can likely find already setup online.
Am I on track to answer your question?
I am trying to put a number picker in a form in MS Access 2007. Here's an example of what I am trying to make:
I cannot find this in the default form controls, and have tried to make one myself using a listbox. Listboxes can be modified to look just like the number picker above, however the arrows only change the view, of the list, and not the actual selection (that is the value). For example, with the list box, if I have it range from 1 to 3, and default at 1 - when I change it to 2 via the arrows, the value of the listbox does not change, and is still one.
Does anyone know how to get a number picker in Access?
So you want to create a list of numbers and allow users to change the value displayed (AND stored as the control's value) using up and down arrows, such that they select the next or previous in the list.
I would suggest creating a text box and two buttons. Populate an array with the list of values. When a button is clicked it would:
A. Find the position in the array of any value already entered into the text box (eg loaded from a database)
B. Get the next or previous item from the array.
The array is populated as required (probably when the form is opened).
If you just need to allow the user to enter a whole integer number (ie a number spinner) you would do as follows:
Create one using a (locked) textbox and two buttons. Just add a textbox (name it something like txtValue) and two buttons (btnUp and btnDown), then add code like this to the Click event of those buttons:
Private Sub btnUp_Click()
Me.txtValue = Nz(Me.txtValue, 0) + 1
End Sub
Private Sub btnDown_Click()
Me.txtValue = Nz(Me.txtValue, 0) - 1
End Sub
You could add if statements to limit the data being entered
Or you can use a 3rd party control.
http://www.fmsinc.com/microsoftaccess/controls/components/spin-button/index.html
There are probably more, but be aware that using these sorts of controls in Access is unsupported, and there is no guarantee moving forward that they will work in Access. You're far better off using the native methods described earlier.
I want to change a outline view , and add checkbox cell in front of node , and the node have a icon and how to add checkbox in head of the icon?
Download the DragNDropOutlineView sample code from Apple and have a look. It contains all the features you're looking for.
As for adding cells, think of it more in terms of adding columns (a column is designed to hold one cell of a single type). If you want more controls in each row, add a new column and set its cell type. Both of these actions can be performed easily in Interface Builder. You can select the table and increase its column count by one (a new column will appear), move the column where you want it (to the beginning), and drag a checkbox-configured button cell (there's a checkbox cell in the IB palette) into the body of the column and its "data cell" prototype will be set. That's it. Just wire it up as you normally would (NSTableViewDataSource or Cocoa Bindings) and you're done.
I am looking for a contol either listbox or listview to support my requirements.
Basically how my application looks is:
alt text http://img51.imageshack.us/img51/451/39967846.png
The background should be black
when the user clicks any 'row' the
row should get highlighted witgh
grey.
The user will have the ability to
search items in this control.
For example , if one of the row
displays 'This is the second Item in
this car'
If the user searches for Car, that corresponding row(s)
should get
highlighted with pink.
The user should be able to search an item in this contol and specify a number to display the lines below the searched row.
For example, if the user Searched for 'car' 5, the rows that have car should get highlighted and their immediate 5 rows.
I mean
Search Result :
car row
next row 1
next row 2
next row 3
next row 4
next row 5
car row
next row 1
next row 2
next row 3
next row 4
next row 5
The user
should be able to drag and drop the
files and they should get opened in
this 'control' i.e each row should
display a new line till the EOF.
The user
will have the ability to right click
on the row, context menu pops up
displaying that row item.
The contol
should be able to display specific
text items in a row(s) with
different color.
Having said these things. I used to program in VC++6, VB6. But using those version now seems not realistic now as I lost touch. But if I have to use the latest 2008 versions, for which I do not have any experience seems scary.
So, If you are reading this , and you have got some experience in these fields or using controls that support my requirement, can you please let me know which programming language or IDE and Control should I use to develop this application.
PS: the image is made using mspaint and does not represent actual program.
As for language I would suggest either C# or VB.Net. They are both great languages and there is tons of support on the Internet for them. Just pick the one you are most comfortable with. As for a control that does what you are asking,
As for the control, it really depends on what platform you target. I have very little experience with WPF so can't help you with that. However, if you want to use WinForms, I would suggest the ListView control. It provides a lot of flexibility in terms of how you can use it. You will need to write the code to identify the rows and highlight them, but that shouldn't be too difficult once you understand how the ListView works.
Here are a couple tips if you do use ListView:
Set ListView.View to Details (this provides you with a grid-like control)
Set ListView.HideSelection to false
Set ListView.FullRowSelect to true
Set ListView.BackColor to Black
Set ListView.ForeColor to White
You can hide the column headers by setting ListView.HeaderStyle to None
If you want to support selecting multiple rows, you can set ListView.MultiSelect to true
To highlight row, set the ListViewItem.BackColor and ForeColor
The big let down of this control is that you don't have much control over the color of selected rows. There are techniques out there to control this, but it's not a simple property set. If you are interested, I think this question/answer might help.